简体   繁体   English

弹性搜索查询字符串到词条查询

[英]Elastic search query string to term query

I've got the following elastic search (0.90) query which return hits based on the id field with combinations of OR operator between them. 我有以下elastic search (0.90)查询,该查询根据id字段(其中包含OR运算符的组合elastic search (0.90)返回匹配。 It's working perfectly. 运行良好。

$query = '{
    "fields": "position",
    "query": {
        "query_string": {
            "query": "id:rs6663158 id:rs6695131",
            "default_operator": "OR"
        }
    }
}';

I wish to do the same with a much simpler query and I found the term option and I have the following which is working fine: 我希望对一个简单得多的查询执行相同的操作,并且找到了term选项”,并且以下各项工作正常:

$query = '{
    "fields": "position",
    "query": {
        "term": {
            "id": "rs6663158",
            "default_operator": "OR"
        }
    }
}';

I'm not sure how to add more than 1 id field like: "id": ["rs6663158", "rs7221234"] . 我不确定如何添加多个id字段,例如: "id": ["rs6663158", "rs7221234"] Is it possible to do this with term option, if not is there any other better and simpler solution? 如果没有其他更好更好的解决方案,是否可以使用term选项来做到这一点?

Using the terms query, like this 使用terms查询,像这样

$query = '{
    "fields": "position",
    "query": {
        "terms": {
            "id": ["rs6663158", "rs6695131"]
        }
    }
}';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM