From 50f4da2a46f846811df2845ee042d0ab59d490ca Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 20 Nov 2019 01:21:51 -0800 Subject: [PATCH] track_total_hits only applies to ES 7 --- README.md | 4 ++-- lib/searchkick/query.rb | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 93076b6..6eee192 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ Get the full response from Elasticsearch results.response ``` -**Note:** By default, Elasticsearch [limits paging](#deep-paging-master) to the first 10,000 results for performance. This applies to the total count as well. +**Note:** By default, Elasticsearch [limits paging](#deep-paging-master) to the first 10,000 results for performance. With Elasticsearch 7, this applies to the total count as well. ### Boosting @@ -1528,7 +1528,7 @@ class Product < ApplicationRecord end ``` -If you just need an accurate total count, you can instead use: +If you just need an accurate total count with Elasticsearch 7, you can instead use: ```ruby Product.search("pears", body_options: {track_total_hits: true}) diff --git a/lib/searchkick/query.rb b/lib/searchkick/query.rb index 1aed600..b80c932 100644 --- a/lib/searchkick/query.rb +++ b/lib/searchkick/query.rb @@ -518,7 +518,7 @@ module Searchkick # routing @routing = options[:routing] if options[:routing] - if searchkick_options[:deep_paging] + if searchkick_options[:deep_paging] && !below70? payload[:track_total_hits] = true end -- libgit2 0.21.0