| Hello, There is currently no way to do this with Elasticsearch, because:
- Index-time analyzer selection (that you seem to use in your forum post) cannot work with remote analyzers
- The fieldbridge API currently doesn't allow to define specific analyzers for bridge-defined fields
We could add a way in the API to define specific analyzers for bridge-defined fields. We would need to:
- Add a FieldMetadataCreationContext analyzer(String analyzerName) method to FieldMetadataCreationContext
- Implement FieldMetadataBuilderImpl#analyzer(String analyzerName) so that it:
- translates the string to an analyzer reference. We currently do something similar in org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.determineAnalyzer(Field, XProperty, ConfigContext, ParseContext)
- registers the analyzer reference in the holding type's scoped analyzer. We currently do something similar in org.hibernate.search.engine.metadata.impl.AnnotationMetadataProvider.bindFieldAnnotation(...), just after the call to determineAnalyzer.
- Add a private AnalyzerReference analyzerReference attribute to BridgeDefinedField, and populate it through its constructor when we call it in FieldMetadataBuilderImpl
- Take this analyzer reference into account in *Elasticsearch*SchemaTranslator#org.hibernate.search.elasticsearch.schema.impl.DefaultElasticsearchSchemaTranslator.addPropertyMapping(ElasticsearchMappingBuilder, ElasticsearchIndexSettingsBuilder, BridgeDefinedField): replace the "null" in the call to addIndexOptions by the analyzer reference
- And obviously, add test cases for the whole thing in the -engine module. They should be automatically re-executed in the -elasticsearch module.
We will work on that eventually, but feel free to give it a shot if you want! |