Convert MySQL query to Elasticsearch query


We're considering moving to ELK, so I just started learning ES and I need to convert our MySQL query into Elasticsearch so we can benchmark the performance of both, but everything's still a bit confusing..

Can anyone help me convert this simple query into an ES query?

SELECT count(*)
		FROM words_list
		WHERE  domain_id = 58 AND type_id IN (5, 3)
	)as our_data
		SELECT word_id 
		FROM words_list
		WHERE type_id = 5
	) as other_data
	ON our_data.word_id=other_data.word_id

Elasticsearch does not performs subselects nor joins like that. At best, you can do join-like queries using nested or parent/child mappings, but that also has a few caveats.

The recommended is to denormalize data in Elasticsearch.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.