Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion docs/reference/mapping/types/parent-join.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@ To index a document with a join, the name of the relation and the optional paren
of the document must be provided in the `source`.
For instance the following creates two parent documents in the `my_parent` context:

[source,js]
--------------------------------------------------
PUT my_index/doc/1?refresh
{
"text": "This is a parent document",
"my_join_field": {
"name": "my_parent" <1>
}
}

PUT my_index/doc/2?refresh
{
"text": "This is a another parent document",
"my_join_field": {
"name": "my_parent"
}
}
--------------------------------------------------
// CONSOLE
// TEST[continued]

<1> This document is a `my_parent` document.

When indexing parent documents, you can choose to specify just the name of the relation
as a shortcut instead of encapsulating it in the normal object notation:

[source,js]
--------------------------------------------------
PUT my_index/doc/1?refresh
Expand All @@ -51,7 +77,7 @@ PUT my_index/doc/2?refresh
// CONSOLE
// TEST[continued]

<1> This document is a `my_parent` document.
<1> Simpler notation for a parent document just uses the relation name.

When indexing a child, the name of the relation as well as the parent id of the document
must be added in the `_source`.
Expand Down