【发布时间】:2017-09-25 11:52:58
【问题描述】:
我的关键字查询有问题。
我想按键和值过滤 categoryProperties。
key 为“color”,value 包含“mavi”
但它给了我文档,它包含键是“颜色”,值包含“Beyaz”
你知道为什么吗?
请求 我在下面查询 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"
}
}
}
}
}
}
}
}
}
}
}
}
【问题讨论】:
标签: elasticsearch keyword-search