What is the ElasticSearch equivalent for an SQL subquery?

Can you logically nest queries in ElasticSearch, so the output of one query is the entrance to another query. Another way to ask, how can I combine or combine queries?

This should be similar to an IN statement or subqueries in SQL

i.e:. - select au_lname, au_fname, heading from (select au_lname, au_fname, au_id from pubs.dbo.authors where state = 'CA') or

SELECT Name FROM AdventureWorks2008R2.Production.Product WHERE ListPrice = (SELECT ListPrice FROM AdventureWorks2008R2.Production.Product WHERE Name = 'Chainring Bolts');

+5
elasticsearch
source share
2 answers

Elasticsearch does not support subqueries; you will need to complete your first query and then build a second query using the results of the first query as input.

+9
source share

This is absolutely correct; you must program the subquery in your favorite programming language. An example can be found here:

http://www.sebastianviereck.de/en/elasticsearch-subquery-scoring-optimization/

0
source share

All Articles