2
我遇到关键字查询问题。ElasticSearch:关键字查询不起作用
我想按键和值过滤categoryProperties。
关键是“颜色”和值包含“马维”
但它给我的文件包含密钥“颜色”和值包含“Beyaz”
你有任何想法,为什么?
REQUEST 我在下面查询searchQuery.categoryProperties.key和searchQuery.categoryProperties.values.value。
{
"query": {
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"must": [{
"nested": {
"query": {
"bool": {
"should": [{
"bool": {
"must_not": [{
"term": {
"searchQuery.categoryProperties.key": {
"value": "color"
}
}
}]
}
},
{
"bool": {
"must": [{
"term": {
"searchQuery.categoryProperties.key": {
"value": "color"
}
}
},
{
"nested": {
"query": {
"term": {
"searchQuery.categoryProperties.values.value": {
"value": "Mavi"
}
}
},
"path": "searchQuery.categoryProperties.values"
}
}]
}
}]
}
},
"path": "searchQuery.categoryProperties"
}
}]
}
},
"path": "searchQuery"
}
}]
}
}
}
这里是我的 响应
{
"hits": {
"total": 1,
"max_score": null,
"hits": [{
"_index": "favoritesearchsearchmodelindex_2",
"_type": "favoritesearchsearchmodel",
"_id": "76175",
"_score": null,
"_source": {
"searchQuery": {
"categoryProperties": [
{
"key": "color",
"values": [{
"value": "Beyaz"
}]
}]
}
}
}]
}
}
我的文档的映射: 映射
{
"favoritesearchsearchmodelindex_2": {
"mappings": {
"favoritesearchsearchmodel": {
"properties": {
"searchQuery": {
"type": "nested",
"properties": {
"categoryProperties": {
"type": "nested",
"properties": {
"intValue": {
"type": "integer"
},
"key": {
"type": "keyword"
},
"values": {
"type": "nested",
"properties": {
"value": {
"type": "keyword"
}
}
}
}
}
}
}
}
}
}
}
}