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]', ...}, ...]
116 117 118 119 120 |
# File 'lib/swiftype/client.rb', line 116 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]', ...}, ...]
191 192 193 194 195 |
# File 'lib/swiftype/client.rb', line 191 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]', ...}, ...]
78 79 80 81 82 |
# File 'lib/swiftype/client.rb', line 78 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]', ...}, ...]
155 156 157 158 159 |
# File 'lib/swiftype/client.rb', line 155 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 |