Can I in elasticsearch express a query that is similar to the following sql query?
select * from data where data.uid in(select d2.uid from data d2 where d2.colX='val1');
Can I in elasticsearch express a query that is similar to the following sql query?
select * from data where data.uid in(select d2.uid from data d2 where d2.colX='val1');
There are two possible solutions.
You can first run a query to get a list of IDs and then use those IDs to run a second query (terms query). Use this approach if you know that the result of the first query will stay under 65,536 IDs/terms. Elasticsearch has a default limit on this amount. You shouldn't increase this limit, it's there for a reason!
You can use nested or a parent/child documents. The main difference is that nested are faster compared to parent/child, but, nested docs require reindexing the parent with all its children, while parent child allows to reindex / add / delete specific children. I don't have enough context to know which type of join will work best in your case.
If Elasticsearch is not a requirement, you might want to take a look at Clickhouse. It supports join queries out of the box (in an SQL way).