im not able to convert my mysql query into elasticsearch query

The name of the pictureThe name of the pictureThe name of the pictureClash 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";





Are you looking to convert from sql to spring-data-elasticsearch or from sql to elasticsearch like @user3775217 answer ? You should check some Elasticsearch and Spring data es documentation before asking that kind of question
– Maelig
Aug 6 at 8:10



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.

Popular posts from this blog

make 2 or more post in bootsrap

Store custom data using WC_Cart add_to_cart() method in Woocommerce 3

Firebase Auth - with Email and Password - Check user already registered