如何用Elasticsearch实现类似SQL中的IN查询实例
我想实现类似如下sql语句的效果:
select * from table1 where rw_id in ('7a482589-e52e-0887-4dd5-5821aab77eea','c68ace46-1c07-fccf-1cb6-57d4e77e40a2','3c9263d2-c44b-a9fd-155e-57aaf783ed58','69b087df-eb62-3e70-2cc0-582ec84a561b')
相应的ES查询应该写为:
$v 即为 rw_id的集合,GET /_search
{ "query": { "filtered": { "filter": { "or" :{ "term": { "rw_id": "7a482589-e52e-0887-4dd5-5821aab77eea" }, "term": { "rw_id": "c68ace46-1c07-fccf-1cb6-57d4e77e40a2" }, "term": { "rw_id": "3c9263d2-c44b-a9fd-155e-57aaf783ed58" }, "term": { "rw_id": "69b087df-eb62-3e70-2cc0-582ec84a561b" } } } } } }