Skip to content

Commit

Permalink
NGSTACK-843 document factory documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Katarina Miočić committed Sep 10, 2024
1 parent b628a66 commit 258439d
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
32 changes: 32 additions & 0 deletions docs/reference/document_mapper.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
DocumentFactory
===============
DocumentFactory is an implementation of field mappers for Elasticsearch modeled after the Solr implementation using the
template method pattern. It implements the Elasticsearch ``DocumentFactoryInterface`` and its methods ``fromContent()``
and ``fromLocation()`` add fields to document. These methods index the fields from the suitable field mappers.

``DocumentFactory`` depends on the elasticsearch service ``DocumentFactoryInterface`` , so it is registered in a
Compiler Pass since elasticsearch is not available directly from the bundle.

To use this feature, ensure you have elasticsearch bundle added to your project.

The ``DocumentFactory`` service uses all base field mapper services to index content into the correct document
(content, location, or translation-dependent document)::

ContentFieldMapper
LocationFieldMapper
ContentTranslationFieldMapper
LocationTranslationFieldMapper
BlockFieldMapper
BlockTranslationFieldMapper

These services are abstract classes containing methods ``accept()`` and ``mapFields()`` which are implemented by new
field mappers as needed.

To add a new field mapper, create a class that extends one of the base field mappers above, implements its methods, and
registers the service with one of the following tags, depending on the base field mapper::

netgen.ibexa_search_extra.elasticsearch.field_mapper.content
netgen.ibexa_search_extra.elasticsearch.field_mapper.location
netgen.ibexa_search_extra.elasticsearch.field_mapper.content_translation
netgen.ibexa_search_extra.elasticsearch.field_mapper.location_translation
netgen.ibexa_search_extra.elasticsearch.field_mapper.block_translation
2 changes: 2 additions & 0 deletions docs/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ Reference
subdocuments
spellcheck_suggestions
extra_fields
asynchronous_indexing
document_mapper

.. include:: /reference/map.rst.inc
1 change: 1 addition & 0 deletions docs/reference/map.rst.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* :doc:`/reference/subdocuments`
* :doc:`/reference/spellcheck_suggestions`
* :doc:`/reference/extra_fields`
* :doc:`/reference/document_mapper`

0 comments on commit 258439d

Please sign in to comment.