Skip to content

Commit 113a696

Browse files
committed
NGSTACK-836 add documentation for descendant indexing
1 parent 8517964 commit 113a696

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
Descendant indexing
2+
=====================
3+
4+
This feature helps in indexing hierarchical content structures. It allows the children of a content item to be indexed
5+
within the same document as the parent if both are configured for descendant indexing.
6+
7+
''Configuration''
8+
9+
To enable this feature, set up the descendant indexing configuration:
10+
11+
.. code-block:: yaml
12+
hierarchical_indexing:
13+
descendant_indexing:
14+
enabled: false
15+
map:
16+
content_type_identifier:
17+
handlers:
18+
- handler_identifier_1
19+
- handler_identifier_2
20+
children:
21+
content_type_identifier:
22+
indexed: true
23+
24+
The ``enabled`` field must be set to true to activate descendant indexing services by registering them in the container.
25+
In the array parameter ``map`` we define the structure of content to be included in descendant indexing by content types.
26+
Any structure in the content tree that matches the configuration will be part of descendant indexing. Content can be
27+
part of the structure but not included in the index. To index the content in the parent document, set the ``indexed```
28+
parameter to ``true``.
29+
30+
This feature is automatically triggered during indexing when configured correctly.
31+
32+
Depending on what we want to index, we use different handlers. They represent the field mappers used to index the content.
33+
If you want to index content to the full text fields, you should use the 'ng_descendant_indexing_fulltext' handler:
34+
35+
.. code-block:: yaml
36+
hierarchical_indexing:
37+
descendant_indexing:
38+
enabled: true
39+
map:
40+
content_type_identifier:
41+
handlers:
42+
- ng_descendant_indexing_fulltext
43+
children:
44+
content_type_identifier:
45+
indexed: true
46+
47+
To index something other than full text fields (e.g., location information or content metadata), implement new field
48+
mappers by extending the corresponding ``BaseFieldMapper`` and registering the field mapper as a service with needed tag.
49+
The ``getIdentifier()`` method returns a string of handler identifier which should match the handler
50+
identifier defined in the configuration.
51+
52+
.. code-block:: php
53+
public function getIdentifier(): string
54+
{
55+
return 'ng_descendant_indexing_fulltext';
56+
}
57+
58+
''AncestorIndexer''
59+
60+
AncestorIndexer is a service that ensures descendant indexing is considered during reindexing. For example, if we edit
61+
content that is part of the descendant indexing map, the descendant content in which it is indexed should also be
62+
reindexed.
63+
64+
The service contains methods ``indexSingle()`` and ``indexMultiple()``, which are called in handlers for any content
65+
changes (e.g., ``CopyContentHandler``, ``DeleteContentHandler``). These methods use the AncestorResolver service to
66+
resolve the ancestor to be reindexed. If no ancestor matches the configuration map structure, the ``resolveAncestor()``
67+
method returns null.
68+
69+
The AncestorResolver service uses AncestorPathGenerator service to read from the configuration and return an array of
70+
strings representing all of the paths matching the given configuration in order to be able to find a match with any of
71+
the paths.

0 commit comments

Comments
 (0)