ES - SQL query equivalent

SQL Query
Select * from posts where userid in (Select userid from users where username like 'Mr%')

I am wanting to get the results from posts for those userid's.
Userid exists in both index's but the username only exists in the users index.

Can someone help me with designing the ES query that would result in the same way as the SQL Query?
Please and Thank-you

Anyone have any input on the above? Is this not possible to have results from one query affect the results from another.

For very simple forms of this, you can use https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html. Otherwise, you'll need to either denormalize the data or perform multiple queries.

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