joining-queries.asciidoc 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. [[joining-queries]]
  2. == Joining queries
  3. Performing full SQL-style joins in a distributed system like Elasticsearch is
  4. prohibitively expensive. Instead, Elasticsearch offers two forms of join
  5. which are designed to scale horizontally.
  6. <<query-dsl-nested-query,`nested` query>>::
  7. Documents may contain fields of type <<nested,`nested`>>. These
  8. fields are used to index arrays of objects, where each object can be queried
  9. (with the `nested` query) as an independent document.
  10. <<query-dsl-has-child-query,`has_child`>> and <<query-dsl-has-parent-query,`has_parent`>> queries::
  11. A <<parent-join,`join` field relationship>> can exist between
  12. documents within a single index. The `has_child` query returns parent
  13. documents whose child documents match the specified query, while the
  14. `has_parent` query returns child documents whose parent document matches the
  15. specified query.
  16. Also see the <<query-dsl-terms-lookup,terms-lookup mechanism>> in the `terms`
  17. query, which allows you to build a `terms` query from values contained in
  18. another document.
  19. include::nested-query.asciidoc[]
  20. include::has-child-query.asciidoc[]
  21. include::has-parent-query.asciidoc[]
  22. include::parent-id-query.asciidoc[]