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

时间:2018-10-09 08:17:50

标签: elasticsearch

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

如何在Elasticsearch中实现这一目标?

1 个答案:

答案 0 :(得分:1)

您需要将must与必须的bool结合使用。

在这里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"
                    }
                }]
            }
        }]
    }
}

}