im not able to convert my mysql query into elasticsearch query

Clash Royale CLAN TAG#URR8PPP
im not able to convert my mysql query into elasticsearch query
I'm a beginner in Elasticsearch. I recently changed my search db from MySQL to Elasticsearch but I am not able to convert one of my queries. The query is given below.
select * from table
where (col1 = "a" and col2 = "b")
or (col1 = "c" and col2 = "d")
and col3 = "z";
sql
spring-data-elasticsearch
sql
elasticsearch
1 Answer
1
Its all about coming the must and should filters together to workout such queries.
Following query is elasticsearch query for your SQL statement.
GET _search
"query":
"bool":
"must": [
"term":
"col3":
"value": "z"
,
"bool":
"should": [
"bool":
"must": [
"term":
"col1":
"value": "a"
,
"term":
"col2":
"value": "b"
]
,
"bool":
"must": [
"term":
"col1":
"value": "c"
,
"term":
"col2":
"value": "d"
]
]
]
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
Are you looking to convert from
sqltospring-data-elasticsearchor fromsqltoelasticsearchlike @user3775217 answer ? You should check some Elasticsearch and Spring data es documentation before asking that kind of question– Maelig
Aug 6 at 8:10