Search code examples
javahibernatehibernate-search

issue in upgrading hibernate-search v3.4.1.Final to hibernate-search-orm v5.9.3.Final


Earlier I was using hibernate-search v3.4.1.Final and now I'm upgrading my application so i have to use hibernate-search-orm v5.9.3.Final and accordingly I'm using hibernate-entitymanager v5.2.17.Final. So after upgrading those dependencies in my code, i'm getting the following error: -

eclipse suggested error:-

The import org.apache.solr cannot be resolved

for code :-

import org.apache.solr.analysis.StandardTokenizerFactory;

I believe this can be resolved if I add "solr-core" dependency v3.1.0 but i'm not able to resolve this error:-

Multiple markers at this line
    - Class<StandardTokenizerFactory> cannot be resolved to a type
    - StandardTokenizerFactory cannot be resolved to a type
UN_TOKENIZED cannot be resolved or is not a field

on line:-

@AnalyzerDef(tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), name = "en")
@Field(index = Index.UN_TOKENIZED, store = Store.YES)

Can anyone suggest which dependency can be used


Solution

  • This is quite a significant jump in versions. By the way, Hibernate Search 5.9 is already EOL. Consider looking at Hibernate Search 5.11 or 6.1 instead.

    There are a lot of major changes in between your 3.4 and any 5.* versions. I'd suggest taking a look at the migration guides provided here for versions up to 5 and here for versions 5+.

    @Field(index = Index.UN_TOKENIZED)
    

    UN_TOKENIZED means:

    Index the field's value without using an Analyzer, so it can be searched. As no analyzer is used the value will be stored as a single term. This is useful for unique Ids like product numbers.

    So this means that it'll translate to:

    // for Hibernate Search 5+
    // or in Hibernate Search 6+ look at the @KeywordField
    @Field(analyze = Analyze.NO, store = Store.YES)
    

    The import org.apache.solr cannot be resolved

    Hibernate Search now does not rely on Solr anymore. It can work either with Lucene or with Elasticsearch backends. Also, no need to include solr dependency. Instead, look for imports from org.apache.lucene.


    @AnalyzerDef(tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class), name = "en")

    Using @AnalyzerDef is deprecated in Hibernate Search 5. See this section if you still want to use it, otherwise take a look at Programmatic analyzer definition