When ES queries, the total number obtained by response.getHits().getTotalHits() is always 0 When ES queries, the result of obtaining total items by response.getHits().getTotalHits() is always 0

Release notes:

  • es version 7.16.3 version
  • es query java es-client maven version 6.8.0/6.8.6

When querying es data, the total number of query response.getHits().getTotalHits() is always 0

amendment:

  • The version of the es version api is correspondingly upgraded to 7.16.3
  • Query by es CountRequest, CountRequest(indexName,queryBuilder)

Let me talk about the reason, the guess is that the data structure returned by the es version upgrade has changed.

reference blog

When ES queries, the result of getting the total items through response.getHits().getTotalHits() is always 0

One of the above blog solutions does not work, even after upgrading the version:

  1. ES-Client uses version 6.8.3: response.getHits().getTotalHits()

Guess you like

Origin blog.csdn.net/haoweng4800/article/details/130878849