Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the ElasticSearch equivalent for an SQL subquery?

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

This should be analogous to the IN operator or subqueries in SQL

i.e.:- select au_lname, au_fname, title 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' );

like image 417
user48545 Avatar asked Feb 26 '15 04:02

user48545


People also ask

How do I create a subquery in Elasticsearch?

Elasticsearch doesn't support subqueries; you would need to perform your first query, then construct a second query using the results of the first query as an input.

Can you query Elasticsearch with SQL?

Scalable search with scoring ... and SQLWith Elasticsearch SQL, you can access that full text search, blazing speed, and effortless scalability with a familiar query syntax.

What is a query in Elasticsearch?

More Detail. In Elasticsearch, searching is carried out by using query based on JSON. A query is made up of two clauses − Leaf Query Clauses − These clauses are match, term or range, which look for a specific value in specific field.


1 Answers

Elasticsearch doesn't support subqueries; you would need to perform your first query, then construct a second query using the results of the first query as an input.

like image 75
Chris Heald Avatar answered Sep 22 '22 18:09

Chris Heald