I'm using spring boot v3.1.2. I'm trying to implement the search feature using Hibernate search with Lucene. For the configuration, I followed the following documentation
I'm struggling bcz manything have been changed in the latest versions of Hibernate Search ! the searchByQuery returns an empty list even though I expect data to match the query
@RequiredArgsConstructorpublic class ProductRepositoryImpl implements ProductRepository { private final EntityManager entityManager; @Override public List<Product> searchByQuery(String query, Pageable pageable) throws RuntimeException { SearchSession searchSession = Search.session( entityManager ); SearchResult<Product> result = searchSession.search( Product.class ) .where( f -> f.match() .fields( "title", "description" ) .matching( query ) ) .fetch( 20 ); long totalHitCount = result.total().hitCount(); List<Product> hits = result.hits(); return hits; }}I suspect that the data hasn't been indexed yet ! any insights on what I might have overlooked ?
// Product.javaimport org.hibernate.search.mapper.pojo.mapping.definition.annotation.FullTextField;import org.hibernate.search.mapper.pojo.mapping.definition.annotation.Indexed;@Table(name = "products")@Getter@Setter@Builder@AllArgsConstructor@NoArgsConstructor@EqualsAndHashCode@Indexedpublic class Product extends BaseEntity { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer id; @FullTextField private String title; private String code; @FullTextField private String description; ...