我试图找到一种在同一阵列中搜索的方法。
示例数据集
"_id":"23424232",
"vehicule":[
"tags":['kawasaki','suzuki','ducati'],
"tags":['opel','mercedes','ford']
]
如果我搜索某人"川崎" 和"欧宝"在相同的标签阵列中,我希望有0次点击,但弹性找到了客户
查询
"query": {
"bool": {
"must": [
{ "term": { "vehicule.tags" : "kawasaki"}},
{ "term": { "vehicule.tags" : "opel"}}
]
}
}
映射
"vehicule": {
"include_in_parent": true,
"type": "nested",
"properties": {
"tags":{
"type":"string",
"analyzer":"code_tokenizer"
},
我认为这是因为弹性标签是扁平的,我想避免这种情况。我怎么能这样做?
"tags":['kawasaki','suzuki','ducati','opel','mercedes','ford']
答案 0 :(得分:0)
我为我找到了解决方案。
{
"query": {
"nested": {
"path": "vehicule.tags",
"query": {
"bool": {
"must": [
{
"term": {
"vehicule.tags": "suzuki"
}
},
{
"term": {
"vehicule.tags": "opel"
}
}
]
}
}
}
}
}
并为该查询弹性找到0客户:)