Using ElasticSearchProvider with PreProcessFieldDefinition #85
Replies: 2 comments
-
Hi @Interritor, I'm afraid, but this is not possible within Elastic/OpenSearch. Those engines force us to prebuild the structure table, before data gets indexed. And that's also the problem, why preprocessed fields can't work here: Data structure within a However, we introduced this feature to allow filter-like indexing with lucene. With ES/OS - both much more powerful - we actually don't need to use The closest thing would be the ->addSimpleDocumentFieldDefinition([
'name' => 'categories',
'index_transformer' => [
'type' => 'explicit',
'configuration' => [
'type' => 'keyword',
]
],
'data_transformer' => [
'type' => ObjectGetterExtractor::class,
'configuration' => [
'method' => 'getCategories',
'transform_callback' => fn($categories) => array_map(static fn(
CategoryInterface $c
) => $c->getName($normalizerOptions['locale']), $categories),
]
]
]) Or even more complex by using a nested field type: ->addSimpleDocumentFieldDefinition([
'name' => 'field_attributes',
'index_transformer' => [
'type' => 'explicit',
'configuration' => [
'type' => 'nested',
'properties' => [
'attribute_id' => [
'type' => 'integer'
],
'attribute_group_id' => [
'type' => 'integer'
],
'attribute_value' => [
'type' => 'keyword'
],
]
]
],
'data_transformer' => [
'type' => AttributesExtractor::class,
'configuration' => ['locale' => $normalizerOptions['locale'] ?? null, 'range' => false]
]
]) This would allow you to create nested attributes without using any pre-processed field definitions. Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
Hello, with Pimcore 10.5 I must to write Definition class like:
With this class I successfully generate index in ES. But query don't work on it. TO be Query work I must create custom search action and rewrite whole query to ES (drop anything what original bundle code generate):
You can find in this code some customisations too for ordering or filtering by date (if user check it on frontend), or filtering to authors name.... |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I have a little problem, I hope you can help me with that.
I have DocumentDefinition which I want to add a PreProcessFieldDefinition. But it got the error "Pre process field definitions are not allowed in current context (Maybe you are using a pre configured index provider) ".
I found that's because the ElasticSearchProvider is an PreConfiguredIndexProviderInterface.
Is there any way to setup PreProcessFieldDefinition using ElasticSearch as IndexProvider?
I hope you can help. I really need the option to work with PreProcessFieldDefinition.
Or is there any other option? I need way to add definitions based on the return value of an data object method?
I working with following versions (still at Pimcore 10):
dachcom-digital/dynamic-search v2.1.2
dachcom-digital/dynamic-search-data-provider-trinity v2.0.3
dachcom-digital/dynamic-search-index-provider-elasticsearch 2.2.0
Thanks in advance,
Andre
Beta Was this translation helpful? Give feedback.
All reactions