ElasticSearch : IN equivalent operator in ElasticSearch

后端 未结 3 716
无人及你
无人及你 2020-12-04 17:34

I am trying to find ElasticSearch query equivalent to IN \\ NOT in SQL.

I know we can use QueryString query with multiple OR to get the sam

3条回答
  •  醉话见心
    2020-12-04 18:06

    I saw what you requested. And I wrote the source code as below.

    I hope this helps you solve your problem.

    sql query :

    select * from tablename where fieldname in ('AA','BB');
    

    elastic search :

    {
        query :{
            bool:{
                must:[{
                  "script": {
                    "script":{
                      "inline": "(doc['fieldname'].value.toString().substring(0,2).toUpperCase() in ['AA','BB']) == true"
                    }
                  }
                }],
                should:[],
                must_not:[]
            }
        }
    }
    

提交回复
热议问题