File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
elasticsearch-persistence/lib/elasticsearch/persistence/repository/response Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ class Results
3838 #
3939 TOTAL = 'total' . freeze
4040
41+ # The key for accessing the value field in an Elasticsearch query response when 'total' is an object.
42+ #
43+ VALUE = 'value' . freeze
44+
4145 # The key for accessing the maximum score in an Elasticsearch query response.
4246 #
4347 MAX_SCORE = 'max_score' . freeze
@@ -63,7 +67,11 @@ def respond_to?(method_name, include_private = false)
6367 # The number of total hits for a query
6468 #
6569 def total
66- raw_response [ HITS ] [ TOTAL ]
70+ if raw_response [ HITS ] [ TOTAL ] . respond_to? ( :keys )
71+ raw_response [ HITS ] [ TOTAL ] [ VALUE ]
72+ else
73+ raw_response [ HITS ] [ TOTAL ]
74+ end
6775 end
6876
6977 # The maximum score for a query
You can’t perform that action at this time.
0 commit comments