File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
elasticsearch-model/lib/elasticsearch/model Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -5,19 +5,23 @@ module Searching
5
5
module ClassMethods
6
6
7
7
def search ( query_or_payload , options = { } )
8
+ __index_name = options [ :index ] || index_name
9
+ __document_type = options [ :type ] || document_type
10
+
8
11
case
9
12
# search query: ...
10
13
when query_or_payload . respond_to? ( :to_hash )
11
- response = client . search index : index_name , type : document_type , body : query_or_payload . to_hash
14
+ response = client . search index : __index_name , type : __document_type , body : query_or_payload . to_hash
12
15
13
16
# search '{ "query" : ... }'
14
17
when query_or_payload . is_a? ( String ) && query_or_payload =~ /^\s *{/
15
- response = client . search index : index_name , type : document_type , body : query_or_payload
18
+ response = client . search index : __index_name , type : __document_type , body : query_or_payload
16
19
17
20
# search '...'
18
21
else
19
- response = client . search index : index_name , type : document_type , q : query_or_payload
22
+ response = client . search index : __index_name , type : __document_type , q : query_or_payload
20
23
end
24
+
21
25
Response ::Response . new ( self , response )
22
26
end
23
27
You can’t perform that action at this time.
0 commit comments