Class: Elasticsearch::Autocomplete::Search
- Inherits:
-
Object
- Object
- Elasticsearch::Autocomplete::Search
- Extended by:
- ClassMethods
- Defined in:
- lib/elasticsearch/autocomplete/search.rb
Defined Under Namespace
Modules: ClassMethods
Instance Attribute Summary collapse
-
#field ⇒ Object
Returns the value of attribute field.
-
#index ⇒ Object
Returns the value of attribute index.
-
#multisearch ⇒ Object
Returns the value of attribute multisearch.
-
#query ⇒ Object
Returns the value of attribute query.
-
#types ⇒ Object
Returns the value of attribute types.
Instance Method Summary collapse
-
#initialize(index, query, types, multisearch = true, field = nil) ⇒ Search
constructor
A new instance of Search.
- #request ⇒ Object
- #results ⇒ Object
Methods included from ClassMethods
Constructor Details
#initialize(index, query, types, multisearch = true, field = nil) ⇒ Search
Returns a new instance of Search.
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/elasticsearch/autocomplete/search.rb', line 13 def initialize(index, query, types, multisearch=true, field=nil) raise "Specify a field when running a single search." if multisearch == false && field.nil? self.query = query self.types = types_mapped(types) self.index = index self.multisearch = multisearch self.field = field end |
Instance Attribute Details
#field ⇒ Object
Returns the value of attribute field.
11 12 13 |
# File 'lib/elasticsearch/autocomplete/search.rb', line 11 def field @field end |
#index ⇒ Object
Returns the value of attribute index.
11 12 13 |
# File 'lib/elasticsearch/autocomplete/search.rb', line 11 def index @index end |
#multisearch ⇒ Object
Returns the value of attribute multisearch.
11 12 13 |
# File 'lib/elasticsearch/autocomplete/search.rb', line 11 def multisearch @multisearch end |
#query ⇒ Object
Returns the value of attribute query.
11 12 13 |
# File 'lib/elasticsearch/autocomplete/search.rb', line 11 def query @query end |
#types ⇒ Object
Returns the value of attribute types.
11 12 13 |
# File 'lib/elasticsearch/autocomplete/search.rb', line 11 def types @types end |
Instance Method Details
#request ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/elasticsearch/autocomplete/search.rb', line 34 def request @request ||= begin if multisearch MultipleRequest.new(index, query, types) else SingleRequest.new(index, query, types, field) end end end |
#results ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/elasticsearch/autocomplete/search.rb', line 24 def results @results ||= begin if multisearch MultipleResponse.new(types, request) else SingleResponse.new(types, request) end end end |