Need to convert this query in ElasticSearch
WHERE (colD like 'abc%' OR colC like '%abc%') AND (colA IN ('a','b') OR colB IN ('a','b'))
Need to convert this query in ElasticSearch
WHERE (colD like 'abc%' OR colC like '%abc%') AND (colA IN ('a','b') OR colB IN ('a','b'))
What did you try so far?
Which part can’t you convert?
Have a look first at bool query.
{
"query": {
"bool": {
"must": [
{
"dis_max" : {
"queries" : [
{
"wildcard" : { "colD" : "hil*" }
},
{
"wildcard" : { "colC" : "hil*" }
}
]
}
},
{
"match" : { "colA" : "10216" }
}
],
"minimum_should_match": 1
}
}
}
Please format your code using </> icon as explained in this guide. It will make your post more readable.
Or use markdown style like:
```
CODE
```
I edited your post.
The sample query you pasted does not really look like to the one you asked for.
Was:
WHERE (colD like 'abc%' OR colC like '%abc%') AND (colA IN ('a','b') OR colB IN ('a','b'))
And you wrote something with hil* and colA=10216.
Let me give you some advices:
or clauses can be translated as should clauses. and clauses can be translated as must clauses.{
"query": {
"bool": {
"must": [
{
"bool": {
"should": [
{
"wildcard": { "colD": "'abc%" }
},{
"wildcard": { "colC": "'%abc%" }
}
]
}
}, {
"bool": {
"should": [
{
// colA IN ('a','b')
},{
// colB IN ('a','b')
}
]
}
}
]
}
}
}
If you need more help, please provide a full recreation script as described in
It will help to better understand what you are doing.
Please, try to keep the example as simple as possible.
© 2020. All Rights Reserved - Elasticsearch
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant logo are trademarks of the Apache Software Foundation in the United States and/or other countries.