提问要多花一点心思哦

关于ElasticSearch查询的一个问题,以下逻辑查询如何用bool query或是其他query表示

Elasticsearch | 作者 zhwy103 | 发布于2017年05月12日 | 阅读数:6623

GET /_search { "query": { "query_string": { "query": "(content:this OR name:this) AND (content:that OR name:that)" } } }
 
求大神帮忙解答哦~~
已邀请:

Xargin

赞同来自: wengqiankun zhwy103 jnuc093

你的这个逻辑用 sql 比较好表达,可以考虑先写出 sql
再找 sql 转dsl 的工具来转为 dsl
http://www.nlpcn.org:9999/web/

kennywu76 - Wood

赞同来自: zhwy103

POST /_search
{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"term": {
"content": {
"value": "this"
}
}
},
{
"term": {
"name": {
"value": "this"
}
}
}
]
}
},
{
"bool": {
"should": [
{
"term": {
"content": {
"value": "that"
}
}
},
{
"term": {
"name": {
"value": "that"
}
}
}
]
}
}
]
}
}
}

要回复问题请先登录注册