Amazon web services 在弹性搜索中保存数组类型数据并按范围搜索ID
如何在弹性搜索ID时添加数组类型JSON。 因此对于Amazon web services 在弹性搜索中保存数组类型数据并按范围搜索ID,amazon-web-services,elasticsearch,Amazon Web Services,elasticsearch,如何在弹性搜索ID时添加数组类型JSON。 因此对于/documentStoreIndex/notesType/1001 { “index”: 0, “time”:1590652925925, “chracter”:“H” }, { “index”: 1, “time”:1590652925925, “chracter”:“I” } 稍后,我想做一个搜索 1) “为id 1001的索引1获取时间” 2) “获取id为1001的从索引0到1的时间数组” 请提供帮助。您需要
/documentStoreIndex/notesType/1001
{
“index”: 0,
“time”:1590652925925,
“chracter”:“H”
},
{
“index”: 1,
“time”:1590652925925,
“chracter”:“I”
}
稍后,我想做一个搜索
1) “为id 1001的索引1获取时间”
2) “获取id为1001的从索引0到1的时间数组”
请提供帮助。您需要使用 映射: 查询:要访问嵌套类型,需要
"hits" : [
{
"_index" : "index92",
"_type" : "_doc",
"_id" : "XQxiWnIBonxtIN2b07x2",
"_score" : 2.0,
"_source" : {
"field1" : [
{
"index" : 0,
"time" : 1590652925925,
"chracter" : "H"
},
{
"index" : 1,
"time" : 1590652925925,
"chracter" : "I"
}
]
},
"inner_hits" : {
"field1" : {
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "index92",
"_type" : "_doc",
"_id" : "XQxiWnIBonxtIN2b07x2",
"_nested" : {
"field" : "field1",
"offset" : 0
},
"_score" : 1.0,
"_source" : {
"time" : 1590652925925
}
},
{
"_index" : "index92",
"_type" : "_doc",
"_id" : "XQxiWnIBonxtIN2b07x2",
"_nested" : {
"field" : "field1",
"offset" : 1
},
"_score" : 1.0,
"_source" : {
"time" : 1590652925925
}
}
]
}
}
}
}
]
}
如何在PUT调用中插入以下内容?“index”:0,“time”:1590652925925,“chracter”:“H”@SubrataSaha它被添加为一个数组。在映射中,字段被定义为“嵌套的”POST index name/_doc{“field”:“,…”field1:[{“index”:0,“time”:1590652925925,“chracter”:“H”},{“索引”:1,“时间”:1590652925925,“字符”:“I”}]}
{
"query": {
"bool": {
"must": [
{
"term": {
"_id": {
"value": "1000"
}
}
},
{
"nested": {
"inner_hits": { --> returns matched nested objects
"_source": "field1.time"--> select fields to show.
},
"path": "field1",
"query": {
"term": {
"field1.index": {
"value": 1
}
}
}
}
}
]
}
}
}
"query": {
"bool": {
"must": [
{
"term": {
"_id": {
"value": "XQxiWnIBonxtIN2b07x2"
}
}
},
{
"nested": {
"inner_hits": {
"_source": "field1.time"
},
"path": "field1",
"query": {
"range": {
"field1.index": {
"gte": 0,
"lte": 1
}
}
}
}
}
]
}
}
}
"hits" : [
{
"_index" : "index92",
"_type" : "_doc",
"_id" : "XQxiWnIBonxtIN2b07x2",
"_score" : 2.0,
"_source" : {
"field1" : [
{
"index" : 0,
"time" : 1590652925925,
"chracter" : "H"
},
{
"index" : 1,
"time" : 1590652925925,
"chracter" : "I"
}
]
},
"inner_hits" : {
"field1" : {
"hits" : {
"total" : {
"value" : 2,
"relation" : "eq"
},
"max_score" : 1.0,
"hits" : [
{
"_index" : "index92",
"_type" : "_doc",
"_id" : "XQxiWnIBonxtIN2b07x2",
"_nested" : {
"field" : "field1",
"offset" : 0
},
"_score" : 1.0,
"_source" : {
"time" : 1590652925925
}
},
{
"_index" : "index92",
"_type" : "_doc",
"_id" : "XQxiWnIBonxtIN2b07x2",
"_nested" : {
"field" : "field1",
"offset" : 1
},
"_score" : 1.0,
"_source" : {
"time" : 1590652925925
}
}
]
}
}
}
}
]
}