I would like to configure a custom tokenizer for using in my custom analyzer in Hibernate Search (6.0.8) with Spring Boot 2.5.x. According to the documentation (Hibernate Search 6.1.0.Final: Reference Documentation) I should use custom index settings like this:
spring:
jpa:
properties:
hibernate:
search:
enabled: true
backend:
indexes:
Lemma:
analysis:
configurer: class:**.**.CustomAnalysisConfigurer
schema_management:
settings_file: custom/index-settings.json
my custom/index-settings.json looks like
{
"analysis": {
"tokenizer": {
"custom_ngram_tokenizer": {
"type": "ngram",
"min_gram": "2",
"max_gram": "3"
}
}
}
}
And the CustomAnalysisConfigurer looks like
package ***.elasticsearch
import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurationContext
import org.hibernate.search.backend.elasticsearch.analysis.ElasticsearchAnalysisConfigurer
class CustomAnalysisConfigurer : ElasticsearchAnalysisConfigurer {
override fun configure(context: ElasticsearchAnalysisConfigurationContext) {
context.analyzer("customAnalyzer").custom().tokenizer("custom_ngram_tokenizer")
}
}
And I would like to call it in my Entity like
@FullTextField(analyzer = "customAnalyzer")
When I use a default available tokenizer (like ngram
) in CustomAnalysisConfigurer
everything works fine. But I expect Hibernate will create an index for me with the settings from custom/index-settings.json
. It looks like the file isn’t picked up at all. Also tried:
spring:
jpa:
properties:
hibernate:
search:
enabled: true
backend:
analysis:
configurer: class:**.**.CustomAnalysisConfigurer
schema_management:
settings_file: custom/index-settings.json
settings valid for all indexes. But this is also without the wanted result.
PS **.** is just for masking