Module: Swiftype::Client::Search
- Included in:
- Swiftype::Client
- Defined in:
- lib/swiftype/client.rb
Overview
Methods wrapping the Swiftype private search and API endpoints. Using these methods, you can perform full-text and prefix searches over the Documents in your Engine, in a specific DocumentType, or any subset of DocumentTypes. You can also filter results and get faceted counts for results.
For more information, visit the REST API documentation on searching.
Instance Method Summary collapse
-
#search(engine_id, query, options = {}) ⇒ Swiftype::ResultSet
Perform a full-text search over all the DocumentTypes of the provided engine.
-
#search_document_type(engine_id, document_type_id, query, options = {}) ⇒ Swiftype::ResultSet
Perform a full-text search over a single DocumentType in an Engine.
-
#suggest(engine_id, query, options = {}) ⇒ Swiftype::ResultSet
Perform an autocomplete (prefix) search over all the DocumentTypes of the provided engine.
-
#suggest_document_type(engine_id, document_type_id, query, options = {}) ⇒ Swiftype::ResultSet
Perform an autocomplete (prefix) search over a single DocumentType in an Engine.
Instance Method Details
#search(engine_id, query, options = {}) ⇒ Swiftype::ResultSet
Perform a full-text search over all the DocumentTypes of the provided engine.
results = client.search("swiftype-api-example", "glass")
results['videos'] # => [{'external_id' => 'v1uyQZNg2vE', 'title' => 'How It Feels [through Glass]', ...}, ...]
132 133 134 135 136 |
# File 'lib/swiftype/client.rb', line 132 def search(engine_id, query, ={}) search_params = { :q => query }.merge() response = post("engines/#{engine_id}/search.json", search_params) ResultSet.new(response) end |
#search_document_type(engine_id, document_type_id, query, options = {}) ⇒ Swiftype::ResultSet
Perform a full-text search over a single DocumentType in an Engine.
results = client.search_document_type("swiftype-api-example", "videos", "glass")
results['videos'] # => [{'external_id' => 'v1uyQZNg2vE', 'title' => 'How It Feels [through Glass]', ...}, ...]
207 208 209 210 211 |
# File 'lib/swiftype/client.rb', line 207 def search_document_type(engine_id, document_type_id, query, ={}) search_params = { :q => query }.merge() response = post("engines/#{engine_id}/document_types/#{document_type_id}/search.json", search_params) ResultSet.new(response) end |
#suggest(engine_id, query, options = {}) ⇒ Swiftype::ResultSet
Perform an autocomplete (prefix) search over all the DocumentTypes of the provided engine. This can be used to implement type-ahead autocompletion. However, if your data is not sensitive, you should consider using the Swiftype public JSONP API in the user’s web browser for suggest queries.
results = client.suggest("swiftype-api-example", "gla")
results['videos'] # => [{'external_id' => 'v1uyQZNg2vE', 'title' => 'How It Feels [through Glass]', ...}, ...]
94 95 96 97 98 |
# File 'lib/swiftype/client.rb', line 94 def suggest(engine_id, query, ={}) search_params = { :q => query }.merge() response = post("engines/#{engine_id}/suggest.json", search_params) ResultSet.new(response) end |
#suggest_document_type(engine_id, document_type_id, query, options = {}) ⇒ Swiftype::ResultSet
Perform an autocomplete (prefix) search over a single DocumentType in an Engine. This can be used to implement type-ahead autocompletion. However, if your data is not sensitive, you should consider using the Swiftype public JSONP API in the user’s web browser for suggest queries.
results = client.suggest_document_type("swiftype-api-example", "videos", "gla")
results['videos'] # => [{'external_id' => 'v1uyQZNg2vE', 'title' => 'How It Feels [through Glass]', ...}, ...]
171 172 173 174 175 |
# File 'lib/swiftype/client.rb', line 171 def suggest_document_type(engine_id, document_type_id, query, ={}) search_params = { :q => query }.merge() response = post("engines/#{engine_id}/document_types/#{document_type_id}/suggest.json", search_params) ResultSet.new(response) end |