I have set up hibernate with the following maven dependency <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>5.1.0.Final</version> </dependency>
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-entitymanager</artifactId> <version>5.1.0.Final</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-search-orm</artifactId> <version>5.5.3.Final</version> </dependency> <dependency> <groupId>org.springframework.data</groupId> <artifactId>spring-data-jpa</artifactId> <version>1.7.2.RELEASE</version> </dependency>
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>${mysql.driver.version}</version> </dependency>
I have configure Hibernate with indexing using this piece of code jpaProperties.put("hibernate.search.default.directory_provide","filesystem" ); jpaProperties.put("hibernate.search.default.indexBase","C:\\Index" ); This is the code I am running
public List<Deals> findDealBySubcatIdhsearch(long subCatId,String search){ //Option or suboption may be included in future, if needed logger.info("Deal nameeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee"+search+"iiiiiiiiiiid"+subCatId); FullTextEntityManager fullTextEntityManager = org.hibernate.search.jpa.Search. getFullTextEntityManager(em); QueryBuilder qb = fullTextEntityManager.getSearchFactory() .buildQueryBuilder().forEntity(Deals.class).get(); org.apache.lucene.search.Query query = qb .keyword().wildcard().onFields("dealName").matching("*"+search.toLowerCase()+"*") .createQuery();
org.hibernate.search.jpa.FullTextQuery jpaQueryy = fullTextEntityManager.createFullTextQuery(query, Deals.class);
//jpaQueryy.enableFullTextFilter("category").setParameter("categoryId", 1); List<Deals> results = jpaQueryy.getResultList(); logger.info("hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh"+jpaQueryy.getResultSize()+"Subid"+subCatId); if(jpaQueryy.getResultList().size()==0) { query = qb .keyword().onFields("dealName").matching("*"+search.toLowerCase()+"*") .createQuery();
jpaQueryy = fullTextEntityManager.createFullTextQuery(query, Deals.class);
results = jpaQueryy.getResultList(); } List<Deals> output = results.parallelStream() .filter(d -> d.getSubcategories().getSubcategoryId() == subCatId) .collect(Collectors.toList());
return output; } But when i persist a object Hibernate search data is indexed but hibernate search does not fetch the details of the persisted object.There is no error in the console.What is the error?
|