0

I'm upgrading my Elasticsearch cluster from 6.8.X to 7.5.X. I have this breaking change; basically in the REST response, there is a {hits: {total: { value: 123 } } } object instead of a {hits: { total: 123 } } int value.

Elasticsearch provides an parameter that you can add to your searches rest_total_hits_as_int; however, I cannot figure out how to set this on queries being formatted by their java RestHighLevelClient or in their SearchRequest object. (I'm currently using the ES 6.8.0 libraries.)

When I send a request from the 6.8 client to a 7.5 cluster, I always get 0 total hits. I get an error when I send a request from the 7.5 client to the 6.8 cluster. (Not backwards compatible.)

Is there a migration path that I'm missing?

Andrew Rueckert
  • 4,858
  • 1
  • 33
  • 44
  • can you use the client of 7.5.X ? – Amit Jan 14 '20 at 02:13
  • 2
    Is the 7.5.X client backwards compatible? It is my understanding that the newer client isn't backwards compatible with an older cluster. – Andrew Rueckert Jan 16 '20 at 23:42
  • yeah, newer clients may not be compatible and that's the reason ES releases its client for even its cluster minor version like 7.3, 7.4, 7.5 etc. And you should always use the client version of your cluster – Amit Jan 17 '20 at 02:33

1 Answers1

0

Just add this:

searchSourceBuilder.trackTotalHits(true);
titou10
  • 2,814
  • 1
  • 19
  • 42