FOSElasticaBundle
FOSElasticaBundle copied to clipboard
Use of type "constant_keyword"
Hi everyone,
I'm currently trying to use the constant_keyword type to split my index by country.
I'm using v6.1.0 of FOSElasticaBundle
Here is an example of my indexe's declaration in fos_elastica.yaml:
fos_elastica:
indexes:
app.orders_be:
index_name: '%env(ELASTICSEARCH_INDEX_PREFIX)%.orders_be'
persistence:
driver: orm
model: App\Entity\CommandeAppro
provider: ~
listener:
defer: false
logger: true
repository: App\Elastica\Repository\CommandeApproElasticaRepository
elastica_to_model_transformer:
query_builder_method: createSearchQueryBuilder
ignore_missing: true
finder: custom_transformed_finder.orders_be
properties:
<<: *order_properties
country:
property_path: getCountryIsoCode
type: constant_keyword
value: BE
settings:
number_of_shards: 10
app.orders_gb:
index_name: '%env(ELASTICSEARCH_INDEX_PREFIX)%.orders_gb'
persistence:
driver: orm
model: App\Entity\CommandeAppro
provider: ~
listener:
defer: false
logger: true
repository: App\Elastica\Repository\CommandeApproElasticaRepository
elastica_to_model_transformer:
query_builder_method: createSearchQueryBuilder
ignore_missing: true
finder: custom_transformed_finder.orders_gb
properties:
<<: *order_properties
country:
property_path: getCountryIsoCode
type: constant_keyword
value: GB
settings:
number_of_shards: 10
I use custom finder, so it is my services.yaml :
custom_transformed_finder.orders_gb:
class: App\Finder\CustomTransformedFinder
arguments:
- '@fos_elastica.index.app.orders_gb'
- '@fos_elastica.elastica_to_model_transformer.app.orders_gb'
custom_transformed_finder.orders_be:
class: App\Finder\CustomTransformedFinder
arguments:
- '@fos_elastica.index.app.orders_be'
- '@fos_elastica.elastica_to_model_transformer.app.orders_be'
Each index is well created, with good data but the search isn't working that well. Indeed, after digging a bit into the code I think I found that the finder are related to the entity and not the index so on only the last one describe into the fos_elastica.yaml config file will be associated, ignoring/erasing the previous one.
If I search BE (Belgian) order, it works fine but if i try to search for GB (Great Britain) the BE finder is still used.
Am I wrong somewhere at using this ElasticSearch feature or is it unusable at this time due to the way the library is write ?