1
0

joining-queries.asciidoc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. [discrete]
  20. [[joining-queries-notes]]
  21. ==== Notes
  22. [discrete]
  23. ===== Allow expensive queries
  24. Joining queries will not be executed if <<query-dsl-allow-expensive-queries, `search.allow_expensive_queries`>>
  25. is set to false.
  26. include::nested-query.asciidoc[]
  27. include::has-child-query.asciidoc[]
  28. include::has-parent-query.asciidoc[]
  29. include::parent-id-query.asciidoc[]