简体   繁体   English

Elasticsearch术语查询作为子句中的mysql?

[英]Elasticsearch term query as mysql in clause?

In mysql, we can Query as: select * from table1 where (name,age) in (('joe',11),('jim',15)); 在mysql中,我们可以查询为: select * from table1 where (name,age) in (('joe',11),('jim',15));

How can I achieve this in Elasticsearch? 如何在Elasticsearch中实现这一目标?

You need to combine should with must bools. 您需要结合必须的布尔。

Read more here https://www.elastic.co/blog/lost-in-translation-boolean-operations-and-filters-in-the-bool-query 在此处阅读更多信息https://www.elastic.co/blog/lost-in-translation-boolean-operations-and-filters-in-the-bool-query

{
"query": {
    "bool": {
        "should": [{
            "bool": {
                "must": [{
                    "match": {
                        "name": "joe"
                    }
                }, {
                    "match": {
                        "age": "11"
                    }
                }]
            }
        }, {
            "bool": {
                "must": [{
                    "match": {
                        "name": "jim"
                    }
                }, {
                    "match": {
                        "age": "15"
                    }
                }]
            }
        }]
    }
}

} }

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

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