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
38
38
#
39
39
TOTAL = 'total' . freeze
40
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
+
41
45
# The key for accessing the maximum score in an Elasticsearch query response.
42
46
#
43
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
67
75
end
68
76
69
77
# The maximum score for a query
You can’t perform that action at this time.
0 commit comments