У меня проблема с запросом ElasticSearch. Я хотел бы найти документы по двум значениям во вложенном объекте, и у меня должен быть такой результат:
{
"took": 36,
"timed_out": false,
"_shards": {
"total": 6,
"successful": 6,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 6.3647356,
"hits": [
{
"_index": "product2019",
"_type": "product",
"_id": "2561571",
"_score": 6.3647356,
"_source": {
"attribute": [
{
"value": "api gl2",
"type": "887",
"lang": "fr",
"country": "FR",
"numpro": "887"
}
],
"idProduct": "2561571",
"type": "ARTICLE"
}
},
{
"_index": "product2019",
"_type": "product",
"_id": "2562471",
"_score": 6.3647356,
"_source": {
"attribute": [
{
"value": "api gl2",
"type": "887",
"lang": "fr",
"country": "FR",
"numpro": "887"
}
],
"idProduct": "2562471",
"type": "ARTICLE"
}
}
]
}
}
Но с моим запросом у меня не очень хороший результат. Вот мой запрос:
{
"size": 500,
"query": {
"bool": {
"must": {
"nested": {
"query": {
"bool": {
"must": [
{
"term": {
"attribute.numpro": "887"
}
},
{
"term": {
"attribute.value": "api gl2"
}
}
]
}
},
"path": "attribute"
}
},
"minimum_should_match": "1"
}
}
}
с этим запросом результат = 0. Кто-то может объяснить мне, почему у меня нет правильного результата?
и это мое отображение:
{
"mappings":{
"product":{
"properties":{
"type":{
"index":"not_analyzed",
"type":"string"
},
"idProduct":{
"index":"not_analyzed",
"type":"string"
},
"attribute":{
"type":"nested",
"properties":{
"country":{
"index":"not_analyzed",
"type":"string"
},
"lang":{
"index":"not_analyzed",
"type":"string"
},
"type":{
"index":"not_analyzed",
"type":"string"
},
"value":{
"analyzer":"french",
"type":"string",
"fields":{
"value.lowercase":{
"analyzer":"lowercase",
"type":"string"
},
"value.notanalyzed":{
"index":"not_analyzed",
"type":"string"
},
"value.alphanumlower":{
"analyzer":"alphanumlower",
"type":"string"
}
}
},
"numpro":{
"type":"long"
}
}
}
}
}
}
}