问题描述
您能否在 ElasticSearch 中逻辑嵌套查询,因此一个查询的输出是另一个查询的输入.另一种提问方式是如何将查询链接或管道连接在一起?
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?
这应该类似于 SQL 中的 IN 运算符或子查询
This should be analogous to the IN operator or subqueries in SQL
即:-选择 au_lname, au_fname, title from(从 pubs.dbo.authors 中选择 au_lname、au_fname、au_id其中状态 = 'CA')或
i.e.:-select au_lname, au_fname, title from (select au_lname, au_fname, au_id from pubs.dbo.authors where state = 'CA')or
选择名称来自 AdventureWorks2008R2.Production.Product哪里 ListPrice =(选择标价来自 AdventureWorks2008R2.Production.ProductWHERE 名称 = '链环螺栓');
SELECT NameFROM AdventureWorks2008R2.Production.ProductWHERE ListPrice = (SELECT ListPrice FROM AdventureWorks2008R2.Production.Product WHERE Name = 'Chainring Bolts' );
推荐答案
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.
这篇关于SQL 子查询的 ElasticSearch 等效项是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!