elasticsearch多查询条件怎么写?

How to write elasticsearch multiple query condition?

我在elasticsearch模块中存储了一些数据,结构很简单。

[
   {
      "country_id":1,
      "city_id":12,
      "city_name":"Kolkata"
   },
   {
      "country_id":1,
      "city_id":55,
      "city_name":"Delhi"
   },
   {
      "country_id":2,
      "city_id":18,
      "city_name":"Las Vegas"
   },
   {
      "country_id":3,
      "city_id":22,
      "city_name":"Sydney"
   }
]

我需要像

这样的搜索查询
"Select * from table_name where country_id = 1 and city_name like %k%"

如果有人在那里,请帮助我找出上述 sql 查询的确切 elasticsearch 查询。

我试过这个查询,但它产生了错误。

curl -XGET "http://xxx.xxx.xxx.x:9200/xxxx/location_details/_search?size=10" -d '{"query":{"bool":{"must":{"term":{"country_id":"101"}}},{"match_phrase":{"city_name":"a"}}}}'

这是一个好的开始

试试这个:

curl -XPOST "http://xxx.xxx.xxx.x:9200/xxxx/location_details/_search" -d '{
  "size": 10,
  "query": {
    "bool": {
      "must": [
        {
          "term": {
            "country_id": "101"
          }
        },
        {
          "query_string": {
            "query": "city_name:*a*"
          }
        }
      ]
    }
  }
}