I am trying to implement full text search: when the input search text will be "cherry" it should return "cherry 1", "cherry", "cherry 5", "cherry101", "cherryfruit". But it is only matching "cherry 1", "cherry", "cherry 5" not "cherry101", "cherryfruit".
My project is in Java spring boot with Mysql and I am using Hibernate with lucene backend version 6.1.7.Final.
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm</artifactId>
<version>6.1.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-backend-lucene</artifactId>
<version>6.1.7.Final</version>
</dependency>
I am following the documentation but it does not work the same way it is described: https://docs.jboss.org/hibernate/stable/search/reference/en-US/html_single/#getting-started-analysis
I added the following code:
package org.hibernate.search.documentation.analysis;
import org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurationContext;
import org.hibernate.search.backend.lucene.analysis.LuceneAnalysisConfigurer;
public class MyLuceneAnalysisConfigurer implements LuceneAnalysisConfigurer {
@Override
public void configure(LuceneAnalysisConfigurationContext context) {
context.analyzer( "english" ).custom()
.tokenizer( "standard" )
.tokenFilter( "lowercase" )
.tokenFilter( "snowballPorter" )
.param( "language", "English" )
.tokenFilter( "asciiFolding" );
context.analyzer( "name" ).custom()
.tokenizer( "standard" )
.tokenFilter( "lowercase" )
.tokenFilter( "asciiFolding" );
}
}
added the property in the application.properties file
spring.jpa.properties.hibernate.search.backend.analysis.configurer=class:org.hibernate.search.documentation.analysis.MyLuceneAnalysisConfigurer
And added the follwing
@FullTextField(analyzer = "name")
private String name;