From 8a6d277073da50cd69f91ee440f3ad2db9cc3aaf Mon Sep 17 00:00:00 2001 From: Alexander Schwirjow Date: Fri, 14 Jan 2022 15:43:32 +0000 Subject: [PATCH 1/3] Update context guard example --- docs/200_ContextGuard.md | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/docs/200_ContextGuard.md b/docs/200_ContextGuard.md index 6cdddbe..10ee48b 100644 --- a/docs/200_ContextGuard.md +++ b/docs/200_ContextGuard.md @@ -1,6 +1,6 @@ # Context Guard -The context guard add an additional layer of protection and controll ontop of the set of your indexing rules. It allows you to filter the result and avoid indexing unvanted content. +The context guard adds an additional layer of protection and controll on top of the set of your indexing rules. It allows you to filter the result and avoid indexing unwanted content. To implement a guard add a service that would implement `ContextGuardInterface`. @@ -12,7 +12,7 @@ services: tags: - { name: dynamic_search.context_guard } ``` -This simple guard will prevent the document with the id 1 (it is the root document in the pimcore document tree) to be added to the index. +This simple guard will prevent the document with the id 1 (it is the root document in the pimcore document tree) to be added to the index. It does not check the object type, so it will filter assets and data objects as well. ``` php getResourceId() > 1) { return true; From 5ab540618ad7e4c8b3508e56d0754dd1201852c9 Mon Sep 17 00:00:00 2001 From: Alexander Schwirjow Date: Mon, 28 Mar 2022 08:07:30 +0000 Subject: [PATCH 2/3] Add simple example for a document --- docs/0_ExampleSetup.md | 106 ++++++++++++++++++++++++++++++++++------- 1 file changed, 90 insertions(+), 16 deletions(-) diff --git a/docs/0_ExampleSetup.md b/docs/0_ExampleSetup.md index 90e1cbd..efc96ab 100644 --- a/docs/0_ExampleSetup.md +++ b/docs/0_ExampleSetup.md @@ -39,10 +39,14 @@ return [ Create a YAML file in your configuration directory ``` yaml -# config/config/dynamic-search.yml +# config/packages/dynamic-search.yaml services: - App\DynamicSearch\IndexDefinition\Trinity\Definition: + App\DynamicSearch\IndexDefinition\TrinityDocument: + tags: + - { name: dynamic_search.document_definition_builder } + + App\DynamicSearch\IndexDefinition\Object\Car: tags: - { name: dynamic_search.document_definition_builder } @@ -61,7 +65,7 @@ dynamic_search: index_object: true object_class_names: - Car - index_document: false + index_document: true index_asset: false full_dispatch: document_limit: 10 @@ -96,7 +100,7 @@ dynamic_search: paginator: enabled: true # adapter_class: '' - max_per_page: 1 + max_per_page: 10 normalizer: service: 'lucene_document_key_value_normalizer' #options: @@ -113,26 +117,19 @@ dynamic_search: reference: search ``` -And link it into your main config. To do so update the imports block at the top. Alternatively, you can just add another `imports` at the bottom. - -```yaml -# config/config/config.yml -imports: - - { resource: dynamic-search.yml } +Symfony will detect the config in `config/packages` automaticly, you do not have to link it. -``` - -## Definition +## Definition for a DataObject ```php getResourceCollectionType() !== 'document') { + return false; + } + + return true; + } + + public function buildDefinition(DocumentDefinitionInterface $definition, array $normalizerOptions): DocumentDefinitionInterface + { + $definition + ->addSimpleDocumentFieldDefinition([ + 'name' => 'id', + 'index_transformer' => [ + 'type' => 'keyword', + ], + 'data_transformer' => [ + 'type' => 'element_id_extractor', + ] + ]) + ->addSimpleDocumentFieldDefinition([ + 'name' => 'path', + 'index_transformer' => [ + 'type' => 'text', + ], + 'data_transformer' => [ + 'type' => 'document_path_generator', + ] + ]) + ->addSimpleDocumentFieldDefinition([ + 'name' => 'title', + 'index_transformer' => [ + 'type' => 'text', + ], + 'data_transformer' => [ + 'type' => 'document_meta_extractor', + 'configuration' => [ + 'type' => 'title', + ], + ] + ]) + ->addSimpleDocumentFieldDefinition([ + 'name' => 'description', + 'index_transformer' => [ + 'type' => 'text', + ], + 'data_transformer' => [ + 'type' => 'document_meta_extractor', + 'configuration' => [ + 'type' => 'description', + ], + ] + ]); + + return $definition; + } +} +``` + ## Indexing To index your data, execute folowing in the command line ``` bash -bin/console dynamic-search:run +bin/console dynamic-search:run -v ``` +The parameter `-v` will make thoe output more verbose and can help you to find anny problems in the config. + ## Test You can test your setup in browser using the URL `/dynamic-search/default/j-search?q=xk140` where the `q` parameter is the search queue. From f0c71966fb9908f639d8858689ee3b65500aa10f Mon Sep 17 00:00:00 2001 From: Alexander Schwirjow Date: Wed, 4 May 2022 12:49:40 +0000 Subject: [PATCH 3/3] Fix multiple typos --- docs/0_ExampleSetup.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/0_ExampleSetup.md b/docs/0_ExampleSetup.md index efc96ab..465d2c0 100644 --- a/docs/0_ExampleSetup.md +++ b/docs/0_ExampleSetup.md @@ -117,7 +117,7 @@ dynamic_search: reference: search ``` -Symfony will detect the config in `config/packages` automaticly, you do not have to link it. +Symfony will detect the config in `config/packages` automatically, you do not have to link it. ## Definition for a DataObject ```php @@ -191,7 +191,7 @@ class Car implements DocumentDefinitionBuilderInterface ## Definition for a Document -This definition will only save index for the id, title and meta dascription. If you want to save the content of the page you will have to use the [WebCrawler](https://github.com/dachcom-digital/pimcore-dynamic-search-data-provider-crawler) or read the content using callbacks. This might be a bit more complex, as you need to consider the concept of personalized content and your own set of bricks. +This definition will only save index for the id, title and meta description. If you want to save the content of the page you will have to use the [WebCrawler](https://github.com/dachcom-digital/pimcore-dynamic-search-data-provider-crawler) or read the content using callbacks. This might be a bit more complex, as you need to consider the concept of personalized content and your own set of bricks. ``` php