Hibernate Search 7.0: new field is ignored in wildcard()-search

Hi everyone,
I am new to Hibernate and Hibernate Search. I encountered a weird problem and don’t really now where it stems from and how to analyze/debug it. So hopefully someone has encountered a similar problem and has a solution. I have several Hibernate Entities that I have marked with @Indexed as well as marking die fields to be searched @FullTextField(analyzer = “custom”). Since I do have punctuation in the fields (which is important) I use a custom analyzer:

public class LuceneAnalysisConfig implements LuceneAnalysisConfigurer {

    @Override
    public void configure(LuceneAnalysisConfigurationContext context) {

        // We want to preserve punctuation, therefore we use whitespace for tokenization.
        context.analyzer( "custom" ).custom()
                .tokenizer( "whitespace" )
                .tokenFilter( "lowercase" );
    }
}

For the search operation itself I am using a wildcard-search.

         SearchResult<Order> searchResult = searchSession.search(Order.class)
                    .where(f -> f.bool()
                            .mustNot(f.match()
                                    .field("orderStatus")
                                    .matching("closed")
                            )
                            .must(f.wildcard()
                                            .fields( "id",
                                                            "customer.firstName",
                                                            "customer.lastName",
                                                            "productDetails.comment",
                                                            "productDetails.productOrderDescription")
                                            .matching("*" + searchQuery.toLowerCase() + "*")
                            )
                    )
                    .fetch(pageable.getPageNumber(), pageable.getPageSize());

So far, it works really well! The wildcard search finds part of strings and punctuation is preserved since I have ids with hyphens.

Here is my problem: I added the @FullTextField(analyzer = “custom”) annotation to another existing field, included it in the wildcard search and reindexed with MassIndexer and the new field is completely ignored by the search. I am not sure why?
I’d appreciate any suggestions or solutions anyone might have.

Hey,

If you’ve added a new field you should re-create your schema before indexing again. You could use the dropAndCreateSchemaOnStart on the massindexer (Hibernate Search 7.2.2.Final: Reference Documentation) or do it manually: Hibernate Search 7.2.2.Final: Reference Documentation

1 Like