Skip to content

Commit 64610ff

Browse files
committed
[Docs] Restore section about multi-level parent/child relation in parent-join (#27392)
This section was removed to hide this ability to new users. This change restores the section and adds a warning regarding the expected performance. Closes #27336
1 parent 4c5d7ab commit 64610ff

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

docs/reference/mapping/types/parent-join.asciidoc

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,3 +374,66 @@ PUT my_index
374374
// CONSOLE
375375

376376
<1> `question` is parent of `answer` and `comment`.
377+
378+
==== Multiple levels of parent join
379+
380+
WARNING: Using multiple levels of relations to replicate a relational model is not recommended.
381+
Each level of relation adds an overhead at query time in terms of memory and computation.
382+
You should de-normalize your data if you care about performance.
383+
384+
Multiple levels of parent/child:
385+
386+
[source,js]
387+
--------------------------------------------------
388+
PUT my_index
389+
{
390+
"mappings": {
391+
"doc": {
392+
"properties": {
393+
"my_join_field": {
394+
"type": "join",
395+
"relations": {
396+
"question": ["answer", "comment"], <1>
397+
"answer": "vote" <2>
398+
}
399+
}
400+
}
401+
}
402+
}
403+
}
404+
--------------------------------------------------
405+
// CONSOLE
406+
407+
<1> `question` is parent of `answer` and `comment`
408+
<2> `answer` is parent of `vote`
409+
410+
The mapping above represents the following tree:
411+
412+
question
413+
/ \
414+
/ \
415+
comment answer
416+
|
417+
|
418+
vote
419+
420+
Indexing a grand child document requires a `routing` value equals
421+
to the grand-parent (the greater parent of the lineage):
422+
423+
424+
[source,js]
425+
--------------------------------------------------
426+
PUT my_index/doc/3?routing=1&refresh <1>
427+
{
428+
"text": "This is a vote",
429+
"my_join_field": {
430+
"name": "vote",
431+
"parent": "2" <2>
432+
}
433+
}
434+
--------------------------------------------------
435+
// CONSOLE
436+
// TEST[continued]
437+
438+
<1> This child document must be on the same shard than its grand-parent and parent
439+
<2> The parent id of this document (must points to an `answer` document)

0 commit comments

Comments
 (0)