| 1234567891011121314151617181920212223242526272829303132 | [[joining-queries]]== Joining queriesPerforming full SQL-style joins in a distributed system like Elasticsearch isprohibitively expensive.  Instead, Elasticsearch offers two forms of joinwhich are designed to scale horizontally.<<query-dsl-nested-query,`nested` query>>::Documents may contain fields of type <<nested,`nested`>>. Thesefields are used to index arrays of objects, where each object can be queried(with the `nested` query) as an independent document.<<query-dsl-has-child-query,`has_child`>> and <<query-dsl-has-parent-query,`has_parent`>> queries::A <<parent-join,`join` field relationship>> can exist betweendocuments within a single index. The `has_child` query returns parentdocuments whose child documents match the specified query, while the`has_parent` query returns child documents whose parent document matches thespecified query.Also see the <<query-dsl-terms-lookup,terms-lookup mechanism>> in the `terms`query, which allows you to build a `terms` query from values contained inanother document.include::nested-query.asciidoc[]include::has-child-query.asciidoc[]include::has-parent-query.asciidoc[]include::parent-id-query.asciidoc[]
 |