We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6baae48 commit ed9f449Copy full SHA for ed9f449
elasticsearch-persistence/lib/elasticsearch/persistence/repository/response/results.rb
@@ -38,6 +38,10 @@ class Results
38
#
39
TOTAL = 'total'.freeze
40
41
+ # The key for accessing the value field in an Elasticsearch query response when 'total' is an object.
42
+ #
43
+ VALUE = 'value'.freeze
44
+
45
# The key for accessing the maximum score in an Elasticsearch query response.
46
47
MAX_SCORE = 'max_score'.freeze
@@ -63,7 +67,11 @@ def respond_to?(method_name, include_private = false)
63
67
# The number of total hits for a query
64
68
65
69
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
75
end
76
77
# The maximum score for a query
0 commit comments