Class: Sonic::Channels::Search
- Defined in:
- lib/sonic/channels/search.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#query(collection, bucket, terms, limit = nil, offset = nil, lang = nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/LineLength.
- #suggest(collection, bucket, word, limit = nil) ⇒ Object
Methods inherited from Base
#help, #initialize, #ping, #quit
Constructor Details
This class inherits a constructor from Sonic::Channels::Base
Instance Method Details
#query(collection, bucket, terms, limit = nil, offset = nil, lang = nil) ⇒ Object
rubocop:disable Metrics/ParameterLists, Metrics/LineLength
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/sonic/channels/search.rb', line 4 def query(collection, bucket, terms, limit = nil, offset = nil, lang = nil) # rubocop:disable Metrics/ParameterLists, Metrics/LineLength arr = [collection, bucket, quote(terms)] arr << "LIMIT(#{limit})" if limit arr << "OFFSET(#{offset})" if offset arr << "LANG(#{lang})" if lang execute('QUERY', *arr) do connection.read # ... end end |
#suggest(collection, bucket, word, limit = nil) ⇒ Object
15 16 17 18 19 20 21 22 |
# File 'lib/sonic/channels/search.rb', line 15 def suggest(collection, bucket, word, limit = nil) arr = [collection, bucket, quote(word)] arr << "LIMIT(#{limit})" if limit execute('SUGGEST', *arr) do connection.read # ... end end |