elasticsearch 弹性搜索比较或
我有一个问题:
elasticsearch 弹性搜索比较或,
elasticsearch,
elasticsearch,我有一个问题: { "query": { "bool" : { "must": [ { "match": { "tags": "htc" } }, { "match": { "votype" : 1} }, { "match": { "subtype": 1 } }, { "match": { "deleted": 0 }
{
"query": {
"bool" : {
"must": [
{ "match": { "tags": "htc" } },
{ "match": { "votype" : 1} },
{ "match": { "subtype": 1 } },
{ "match": { "deleted": 0 } },
{ "match": { "build_status": 4 } },
{ "match": { "publish": 1 } }
]
}
},
"sort": [
{ "created": "desc" }
],
"size": 30,
"from": 0
}
我想把它放进一个值列表中
{ "match": { "votype": [1 or 2 or 3] } }
SQL模拟:
SELECT * FROM tablename WHERE type IN(1, 2);
但我不知道该怎么做
不工作:
{ "match": { "votype": [1,3] } },
{ "match": { "votype": "1 2" } },
{ "match": { "votype": "1OR2" } }
这行吗
{ "match": { "votype": "1 2 3" } }
我的解决方案
{
"query": {
"bool" : {
"must": [
{ "terms" : { "tags": ["htc"], "minimum_match": 1 } },
{ "terms" : { "votype" : [1,2], "minimum_match": 1 } },
{ "terms" : { "deleted": [0], "minimum_match": 1 } },
{ "terms" : { "build_status": [4], "minimum_match": 1 } },
{ "terms" : { "publish": [1], "minimum_match": 1 } }
]
}
},
"sort": [
{ "created": "desc" }
],
"size": 30,
"from": 0
}
看一看它的作品!感谢tipI,我想问题是“如何在匹配查询中搜索值列表?”我想我回答了这个问题。我看不出我的答案有什么不对。我误解了这个问题吗?@dadoonet对不起,我在这里扣动扳机有点快。