Вам необходимо сохранить массив, используя вложенный тип
Сопоставление:
PUT index92
{
"mappings": {
"properties": {
"field1":{
"type": "nested"
}
}
}
}
Запрос: Для доступа вложенный тип, требуется вложенный запрос
- Найти do c с индексом 1
{
"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
}
}
}
}
}
]
}
}
}
Получить индекс из диапазона 0-1
"query": {
"bool": {
"must": [
{
"term": {
"_id": {
"value": "XQxiWnIBonxtIN2b07x2"
}
}
},
{
"nested": {
"inner_hits": {
"_source": "field1.time"
},
"path": "field1",
"query": {
"range": {
"field1.index": {
"gte": 0,
"lte": 1
}
}
}
}
}
]
}
}
}
Результат: Innert_hits, указанные в запросах, повторных запросах, соответствующих вложенным документам
"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
}
}
]
}
}
}
}
]
}