1

I upgraded the elastic search from version 5.5 to 7.7, everything is working as expected. But when I try to get the Total hits, I get the following error

searchResponse.getHits().getTotalHits()

The type org.apache.lucene.search.TotalHits cannot be resolved. It is indirectly referenced from required .class files

We are not using the lucene library but still, it says it refers to the lucene, Any help is appreciated to fix this.

enter image description here

Maven pom.xml :

I have only these two Jars,

<dependency>
            <groupId>org.elasticsearch.client</groupId>
            <artifactId>transport</artifactId>
            <version>7.7.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>2.11.1</version>
        </dependency>

Thanks,
Harry

3
  • Could you please update the question with your maven/gradle config, looks like lucene library is missing. Commented Jun 16, 2020 at 7:59
  • @OpsterESNinja-Kamal Updated the pom.xml but previously may be the jars on lucene could have been there, which I removed now Commented Jun 16, 2020 at 8:40
  • You can either go with the below answer if you have not removed the lucene jars or use this link so that maven re-downloads the required dependencies. Commented Jun 16, 2020 at 8:56

1 Answer 1

2

As mentioned this link, you probably need to add the below dependency:

<repository>
    <id>elastic-lucene-snapshots</id>
    <name>Elastic Lucene Snapshots</name>
    <url>https://s3.amazonaws.com/download.elasticsearch.org/lucenesnapshots/00142c9</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>false</enabled></snapshots>
</repository>

Also as per this link, you may also need to add Log4j dependency as well:

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-core</artifactId>
    <version>2.11.1</version>
</dependency>

That should do the trick.

Alternatively you can also add the below lucene dependency with the exact version you can see if you just do http://<hostname>:9200, however I suggest the above approach and go as per their documentation.

<!-- https://mvnrepository.com/artifact/org.apache.lucene/lucene-core -->
<dependency>
    <groupId>org.apache.lucene</groupId>
    <artifactId>lucene-core</artifactId>
    <version>8.5.1</version>
</dependency>

Hope that helps!

Sign up to request clarification or add additional context in comments.

4 Comments

Thanks @Opster ED Ninja Kamal
Sure, will review and update. Please give me sometime!!
Could you please help me on this : stackoverflow.com/questions/62463191/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.