I am using Hibernate search in spring boot for the first time and trying to define my own german synonyms and I am using this code:
@AnalyzerDef(name = "edgeNgram",
tokenizer = @TokenizerDef(factory = WhitespaceTokenizerFactory.class),
filters = {
@TokenFilterDef(factory = ASCIIFoldingFilterFactory.class), // Replace accented characeters by their simpler counterpart (è => e, etc.)
@TokenFilterDef(factory = LowerCaseFilterFactory.class), // Lowercase all characters
@TokenFilterDef(
factory = EdgeNGramFilterFactory.class, // Generate prefix tokens
params = {
@Parameter(name = "minGramSize", value = "2"),
@Parameter(name = "maxGramSize", value = "4")
}
),
@TokenFilterDef(
factory = SynonymFilterFactory.class,
params = {
@Parameter(name = "ignoreCase", value = "true"),
@Parameter(name = "expand", value = "true"),
@Parameter(name = "synonyms", value = "synonyms.txt"),
})
})
when I use "factory = SynonymFilterFactory.class" and define my "synonyms.txt" file I get the error:
Caused by: org.hibernate.search.exception.SearchException: HSEARCH000114: Could not load resource: 'synonyms.txt'
I am new to spring boot and will appreciate any help! thanks
This:
@Parameter(name = "synonyms", value = "synonyms.txt")
Means you're asking Hibernate Search to load a file named synonyms.txt
from your classpath, and extract the list of synonyms from there.
If you don't have a file named synonyms.txt
at the root of your classpath, you'll get this exception.
Add the file and everything should be back in order.
See the javadoc of org.apache.lucene.analysis.synonym.SolrSynonymParser
for an explanation of the format of this file.