WARNING: Version 2.0 of Elasticsearch has passed its EOL date.
This documentation is no longer being maintained and may be removed. If you are running this version, we strongly advise you to upgrade. For the latest information, see the current release documentation.
Joining queries
edit
IMPORTANT: This documentation is no longer updated. Refer to Elastic's version policy and the latest documentation.
Joining queries
editPerforming full SQL-style joins in a distributed system like Elasticsearch is prohibitively expensive. Instead, Elasticsearch offers two forms of join which are designed to scale horizontally.
-
nestedquery -
Documents may contains fields of type
nested. These fields are used to index arrays of objects, where each object can be queried (with thenestedquery) as an independent document. -
has_childandhas_parentqueries -
A parent-child relationship can exist between two
document types within a single index. The
has_childquery returns parent documents whose child documents match the specified query, while thehas_parentquery returns child documents whose parent document matches the specified query.
Also see the terms-lookup mechanism in the terms
query, which allows you to build a terms query from values contained in
another document.