How to store results temporarily or use a subquery

So I did search for use of subqueries but most posts are from several years back, so reposting to make sure there's no feature that's come up recently.

If I have a query that results in a million IDs, how do I query against just those IDs (assuming my index contains over 100 million documents)?

In the relational world you could use store the results in a temp table and reference it in a subsequent query, or you could use a subquery which would contain the logic for the first query. What options are available at this point to do this? Or is there still no support for accomplishing this?


1 Like


You need to do it externally to Elasticsearch, there is nothing it has that can do this natively.

probably you can do it with putting ids into the doc and referring it as a terms query

Not unless you get the terms first, that's the problem.

one thing we could do (which will work only if you relate data to a singular master dataset) is to reindex the results of a query, storing just the master key, establishing a parent child relationship on the created index with the master index, and use it in the form of a join (this gives you the ability to do a subquery only for a singular field, not any field though).

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