mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-06 13:08:29 +00:00
b9dc5acf2c
* Remove remaining 1.x bwc logic. * Stop storing stored fields and indexed terms. The _parent field's only purpose is to support joins between parent and child type and only storing doc values is sufficient. * In the mapping the parent field mapper is now known under '{parent}#{child}' key, because this is the field the parent/child join uses too. * Added new sub fetch phase to lookup that _parent field from doc values field if that is required (before this was fetched from stored _parent field) * Removed the ability to query directly on `_parent` in the query dsl. Instead the `{parent}#{child}` field should be used. Under the hood a doc values query is used instead of a term query, because only doc values fields are stored now. * Added a new `parent_id` query to easily query child documents with a specific parent id without having to know what join field to use * Also in aggregations `_parent` field can't be used any more and `{parent}#{child}` field name should be used instead to aggregate directly on the _parent join field.
35 lines
1.2 KiB
Plaintext
35 lines
1.2 KiB
Plaintext
[[joining-queries]]
|
|
== Joining queries
|
|
|
|
Performing 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.
|
|
|
|
<<query-dsl-nested-query,`nested` query>>::
|
|
|
|
Documents may contains fields of type <<nested,`nested`>>. These
|
|
fields 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 <<mapping-parent-field,parent-child relationship>> can exist between two
|
|
document types within a single index. The `has_child` query returns parent
|
|
documents whose child documents match the specified query, while the
|
|
`has_parent` query returns child documents whose parent document matches the
|
|
specified 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 in
|
|
another document.
|
|
|
|
include::nested-query.asciidoc[]
|
|
|
|
include::has-child-query.asciidoc[]
|
|
|
|
include::has-parent-query.asciidoc[]
|
|
|
|
include::parent-id-query.asciidoc[]
|
|
|
|
|