* Adds hibernate-search to build-all.sh

This commit is contained in:
murtuza-ranapur
2020-10-03 11:44:34 +05:30
parent 316fffdd7c
commit ec52966e5f
3 changed files with 4 additions and 3 deletions

View File

@@ -86,6 +86,7 @@ if [[ "$MODULE" == "module5" ]]
then then
# ADD NEW MODULES HERE # ADD NEW MODULES HERE
# (add new modules above the rest so you get quicker feedback if it fails) # (add new modules above the rest so you get quicker feedback if it fails)
build_gradle_module "spring-boot/hibernate-search"
build_maven_module "spring-boot/spring-boot-logging-2" build_maven_module "spring-boot/spring-boot-logging-2"
build_maven_module "spring-boot/spring-boot-docker" build_maven_module "spring-boot/spring-boot-docker"
build_gradle_module "spring-boot/devtools-demo" build_gradle_module "spring-boot/devtools-demo"

View File

@@ -21,10 +21,10 @@ public class User {
@Field(name = "fullName") @Field(name = "fullName")
private String first; private String first;
@Field(index = Index.NO) @Field(index = Index.NO, store = Store.YES)
private String middle; private String middle;
@Field @Field(store = Store.YES)
@Field(name = "fullName") @Field(name = "fullName")
private String last; private String last;

View File

@@ -67,7 +67,7 @@ public class SearchService {
QueryBuilder qb = fullTextEntityManager.getSearchFactory().buildQueryBuilder() QueryBuilder qb = fullTextEntityManager.getSearchFactory().buildQueryBuilder()
.forEntity(User.class) .forEntity(User.class)
.get(); .get();
Query similarToUser = qb.keyword().fuzzy().withEditDistanceUpTo(3).onField("first") Query similarToUser = qb.keyword().fuzzy().withEditDistanceUpTo(2).onField("first")
.matching(first).createQuery(); .matching(first).createQuery();
Query finalQuery = qb.bool().must(similarToUser).createQuery(); Query finalQuery = qb.bool().must(similarToUser).createQuery();