请帮助将SQL查询转换为Elasticsearch查询

时间:2019-04-10 21:53:11

标签: sql elasticsearch

如何像这样转换SQL查询

ID

在Elasticsearch-query(v6.x)中吗?

2 个答案:

答案 0 :(得分:0)

赞:

POST /IndexA/_search -d '
{
"query" : {
 "bool" : { 
 "must" : [
    {
        "wildcard" : {
                "name" : "*stics*"
        } 
    },
    { 
        "terms" : {
            "_id" : ["1", "2", "3"] 
        }
     }
   ]
  }
 }
}'

答案 1 :(得分:0)

在ES7中,可以轻松完成以下操作:

curl -H "Content-Type:application/json" -XPOST 127.0.0.1:9200/_xpack/sql/translate?pretty -d '{"query" : "select IndexA.* from IndexA where IndexA.NAME like ('%stics%') and IndexA.ID in (1,2,3,4)"}'