我目前正在尝试将基于solr的应用程序迁移到elasticsearch。
我有一个lucene查询:
((
name:(+foo +bar)
OR info:(+foo +bar)
)) AND state:(1) AND (has_image:(0) OR has_image:(1)^100)据我所知,这是must子句与布尔OR的组合。
获取所有包含
(foo AND bar in name) OR (foo AND bar in info)的文档。在此之后,筛选结果由具有图像的条件state=1和boost文档生成。
我一直试图在must中使用bool查询,但未能将布尔OR引入must子句。以下是我所拥有的:
GET /test/object/_search
{
"from": 0,
"size": 20,
"sort": {
"_score": "desc"
},
"query": {
"bool": {
"must": [
{
"match": {
"name": "foo"
}
},
{
"match": {
"name": "bar"
}
}
],
"must_not": [],
"should": [
{
"match": {
"has_image": {
"query": 1,
"boost": 100
}
}
}
]
}
}
}如您所见,must的info条件缺失了。
**更新**
我更新了我的elasticsearch查询,并去掉了这个功能分数。我的基本问题仍然存在。
发布于 2020-03-05 13:02:02
https://stackoverflow.com/questions/28538760
复制相似问题