All URIs are relative to https://api.search.io
Method | HTTP request | Description |
---|---|---|
create_collection | POST /v4/collections | Create collection |
delete_collection | DELETE /v4/collections/{collection_id} | Delete collection |
experiment | POST /v4/collections/{collection_id}:experiment | Experiment |
get_collection | GET /v4/collections/{collection_id} | Get collection |
list_collections | GET /v4/collections | List collections |
query_collection | POST /v4/collections/{collection_id}:query | Query collection |
query_collection2 | POST /v4/collections/{collection_id}:queryCollection | Query collection |
track_event | POST /v4/collections/{collection_id}:trackEvent | Track event |
update_collection | PATCH /v4/collections/{collection_id} | Update collection |
create_collection(collection_id, collection, opts)
Create collection
Create an empty collection. Before records can be added to a collection, the schema and pipelines for the collection have to be set up. Consider setting up new collections via the Search.io Console, which handles the creation of the schema and pipelines for you.
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
collection_id = 'collection_id_example' # String | The ID to use for the collection. This must start with an alphanumeric character followed by one or more alphanumeric or `-` characters. Strictly speaking, it must match the regular expression: `^[A-Za-z][A-Za-z0-9\\-]*$`.
collection = SajariAPIClient::Collection.new({display_name: 'display_name_example'}) # Collection | Details of the collection to create.
opts = {
account_id: 'account_id_example' # String | The account that owns the collection, e.g. `1618535966441231024`.
}
begin
# Create collection
result = api_instance.create_collection(collection_id, collection, opts)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->create_collection: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> create_collection_with_http_info(collection_id, collection, opts)
begin
# Create collection
data, status_code, headers = api_instance.create_collection_with_http_info(collection_id, collection, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <Collection>
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->create_collection_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
collection_id | String | The ID to use for the collection. This must start with an alphanumeric character followed by one or more alphanumeric or `-` characters. Strictly speaking, it must match the regular expression: `^[A-Za-z][A-Za-z0-9\-]*$`. | |
collection | Collection | Details of the collection to create. | |
account_id | String | The account that owns the collection, e.g. `1618535966441231024`. | [optional] |
- Content-Type: application/json
- Accept: application/json
Object delete_collection(collection_id, opts)
Delete collection
Delete a collection and all of its associated data. > Note: This operation cannot be reversed.
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
collection_id = 'collection_id_example' # String | The collection to delete, e.g. `my-collection`.
opts = {
account_id: 'account_id_example' # String | The account that owns the collection, e.g. `1618535966441231024`.
}
begin
# Delete collection
result = api_instance.delete_collection(collection_id, opts)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->delete_collection: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(Object, Integer, Hash)> delete_collection_with_http_info(collection_id, opts)
begin
# Delete collection
data, status_code, headers = api_instance.delete_collection_with_http_info(collection_id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => Object
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->delete_collection_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
collection_id | String | The collection to delete, e.g. `my-collection`. | |
account_id | String | The account that owns the collection, e.g. `1618535966441231024`. | [optional] |
Object
- Content-Type: Not defined
- Accept: application/json
experiment(collection_id, experiment_request)
Experiment
Run a query on a collection with a hypothetical configuration to see what kinds of results it produces. Saved promotions with a start date in the future are enabled during the experiment, unless they are explicitly disabled. The following example demonstrates how to run a simple experiment for a string, against a pipeline and with a proposed promotion: json { \"pipeline\": { \"name\": \"my-pipeline\" }, \"variables\": { \"q\": \"search terms\" }, \"promotions\": [{ \"id\": \"1234\", \"condition\": \"q = 'search terms'\", \"pins\": [{ \"key\": { \"field\": \"id\", \"value\": \"54hdc7h2334h\" }, \"position\": 1 }] }] }
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
collection_id = 'collection_id_example' # String | The collection to query, e.g. `my-collection`.
experiment_request = SajariAPIClient::ExperimentRequest.new({variables: { key: 3.56}}) # ExperimentRequest |
begin
# Experiment
result = api_instance.experiment(collection_id, experiment_request)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->experiment: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> experiment_with_http_info(collection_id, experiment_request)
begin
# Experiment
data, status_code, headers = api_instance.experiment_with_http_info(collection_id, experiment_request)
p status_code # => 2xx
p headers # => { ... }
p data # => <ExperimentResponse>
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->experiment_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
collection_id | String | The collection to query, e.g. `my-collection`. | |
experiment_request | ExperimentRequest |
- Content-Type: application/json
- Accept: application/json
get_collection(collection_id, opts)
Get collection
Retrieve the details of a collection.
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
collection_id = 'collection_id_example' # String | The collection to retrieve, e.g. `my-collection`.
opts = {
account_id: 'account_id_example', # String | The account that owns the collection, e.g. `1618535966441231024`.
view: 'VIEW_UNSPECIFIED' # String | The amount of information to include in the retrieved pipeline. - VIEW_UNSPECIFIED: The default / unset value. The API defaults to the `BASIC` view. - BASIC: Include basic information including display name and domains. This is the default value (for both [ListCollections](/docs/api#operation/ListCollections) and [GetCollection](/docs/api#operation/GetCollection)). - FULL: Include the information from `BASIC`, plus full collection details like disk usage.
}
begin
# Get collection
result = api_instance.get_collection(collection_id, opts)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->get_collection: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> get_collection_with_http_info(collection_id, opts)
begin
# Get collection
data, status_code, headers = api_instance.get_collection_with_http_info(collection_id, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <Collection>
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->get_collection_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
collection_id | String | The collection to retrieve, e.g. `my-collection`. | |
account_id | String | The account that owns the collection, e.g. `1618535966441231024`. | [optional] |
view | String | The amount of information to include in the retrieved pipeline. - VIEW_UNSPECIFIED: The default / unset value. The API defaults to the `BASIC` view. - BASIC: Include basic information including display name and domains. This is the default value (for both ListCollections and GetCollection). - FULL: Include the information from `BASIC`, plus full collection details like disk usage. | [optional][default to 'VIEW_UNSPECIFIED'] |
- Content-Type: Not defined
- Accept: application/json
list_collections(opts)
List collections
Retrieve a list of collections in an account.
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
opts = {
account_id: 'account_id_example', # String | The account that owns this set of collections, e.g. `1618535966441231024`.
page_size: 56, # Integer | The maximum number of collections to return. The service may return fewer than this value. If unspecified, at most 50 collections are returned. The maximum value is 100; values above 100 are coerced to 100.
page_token: 'page_token_example', # String | A page token, received from a previous [ListCollections](/docs/api#operation/ListCollections) call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to [ListCollections](/docs/api#operation/ListCollections) must match the call that provided the page token.
view: 'VIEW_UNSPECIFIED' # String | The amount of information to include in each retrieved collection. - VIEW_UNSPECIFIED: The default / unset value. The API defaults to the `BASIC` view. - BASIC: Include basic information including display name and domains. This is the default value (for both [ListCollections](/docs/api#operation/ListCollections) and [GetCollection](/docs/api#operation/GetCollection)). - FULL: Include the information from `BASIC`, plus full collection details like disk usage.
}
begin
# List collections
result = api_instance.list_collections(opts)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->list_collections: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> list_collections_with_http_info(opts)
begin
# List collections
data, status_code, headers = api_instance.list_collections_with_http_info(opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <ListCollectionsResponse>
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->list_collections_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
account_id | String | The account that owns this set of collections, e.g. `1618535966441231024`. | [optional] |
page_size | Integer | The maximum number of collections to return. The service may return fewer than this value. If unspecified, at most 50 collections are returned. The maximum value is 100; values above 100 are coerced to 100. | [optional] |
page_token | String | A page token, received from a previous ListCollections call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to ListCollections must match the call that provided the page token. | [optional] |
view | String | The amount of information to include in each retrieved collection. - VIEW_UNSPECIFIED: The default / unset value. The API defaults to the `BASIC` view. - BASIC: Include basic information including display name and domains. This is the default value (for both ListCollections and GetCollection). - FULL: Include the information from `BASIC`, plus full collection details like disk usage. | [optional][default to 'VIEW_UNSPECIFIED'] |
- Content-Type: Not defined
- Accept: application/json
query_collection(collection_id, query_collection_request, opts)
Query collection
Query the collection to search for records. The following example demonstrates how to run a simple search for a particular string: json { \"variables\": { \"q\": \"search terms\" } }
For more information: - See filtering content - See tracking in the Go SDK - See tracking in the JS SDK Note: Unlike other API calls, the QueryCollection
call can be called from a browser. When called from a browser, the Account-Id
header must be set to your account ID.
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
collection_id = 'collection_id_example' # String | The collection to query, e.g. `my-collection`.
query_collection_request = SajariAPIClient::QueryCollectionRequest.new({variables: { key: 3.56}}) # QueryCollectionRequest |
opts = {
account_id: 'account_id_example' # String | The account that owns the collection, e.g. `1618535966441231024`. Unlike other API calls, the `QueryCollection` call can be called from a browser. When called from a browser, the `Account-Id` header must be set to your account ID.
}
begin
# Query collection
result = api_instance.query_collection(collection_id, query_collection_request, opts)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->query_collection: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> query_collection_with_http_info(collection_id, query_collection_request, opts)
begin
# Query collection
data, status_code, headers = api_instance.query_collection_with_http_info(collection_id, query_collection_request, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <QueryCollectionResponse>
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->query_collection_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
collection_id | String | The collection to query, e.g. `my-collection`. | |
query_collection_request | QueryCollectionRequest | ||
account_id | String | The account that owns the collection, e.g. `1618535966441231024`. Unlike other API calls, the `QueryCollection` call can be called from a browser. When called from a browser, the `Account-Id` header must be set to your account ID. | [optional] |
- Content-Type: application/json
- Accept: application/json
query_collection2(collection_id, query_collection_request)
Query collection
Query the collection to search for records. The following example demonstrates how to run a simple search for a particular string: json { \"variables\": { \"q\": \"search terms\" } }
For more information: - See filtering content - See tracking in the Go SDK - See tracking in the JS SDK Note: Unlike other API calls, the QueryCollection
call can be called from a browser. When called from a browser, the Account-Id
header must be set to your account ID.
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
collection_id = 'collection_id_example' # String | The collection to query, e.g. `my-collection`.
query_collection_request = SajariAPIClient::QueryCollectionRequest.new({variables: { key: 3.56}}) # QueryCollectionRequest |
begin
# Query collection
result = api_instance.query_collection2(collection_id, query_collection_request)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->query_collection2: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> query_collection2_with_http_info(collection_id, query_collection_request)
begin
# Query collection
data, status_code, headers = api_instance.query_collection2_with_http_info(collection_id, query_collection_request)
p status_code # => 2xx
p headers # => { ... }
p data # => <QueryCollectionResponse>
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->query_collection2_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
collection_id | String | The collection to query, e.g. `my-collection`. | |
query_collection_request | QueryCollectionRequest |
- Content-Type: application/json
- Accept: application/json
Object track_event(account_id, collection_id, event)
Track event
Track an analytics event when a user interacts with an object returned by a QueryCollection request. An analytics event can be tracked for the following objects: - Results - Promotion banners - Redirects When tracking redirect events, set type
to redirect
. Note: You must pass an Account-Id
header.
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
account_id = 'account_id_example' # String | The account that owns the collection, e.g. `1618535966441231024`.
collection_id = 'collection_id_example' # String | The collection to track the event against, e.g. `my-collection`.
event = SajariAPIClient::Event.new({query_id: 'query_id_example', type: 'type_example'}) # Event | The details of the event to track.
begin
# Track event
result = api_instance.track_event(account_id, collection_id, event)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->track_event: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(Object, Integer, Hash)> track_event_with_http_info(account_id, collection_id, event)
begin
# Track event
data, status_code, headers = api_instance.track_event_with_http_info(account_id, collection_id, event)
p status_code # => 2xx
p headers # => { ... }
p data # => Object
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->track_event_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
account_id | String | The account that owns the collection, e.g. `1618535966441231024`. | |
collection_id | String | The collection to track the event against, e.g. `my-collection`. | |
event | Event | The details of the event to track. |
Object
- Content-Type: application/json
- Accept: application/json
update_collection(collection_id, collection, opts)
Update collection
Update the details of a collection.
require 'time'
require 'sdk_ruby'
# setup authorization
SajariAPIClient.configure do |config|
# Configure HTTP basic authorization: BasicAuth
config.username = 'YOUR USERNAME'
config.password = 'YOUR PASSWORD'
end
api_instance = SajariAPIClient::CollectionsApi.new
collection_id = 'collection_id_example' # String | The collection to update, e.g. `my-collection`.
collection = SajariAPIClient::Collection.new({display_name: 'display_name_example'}) # Collection | The details of the collection to update.
opts = {
account_id: 'account_id_example', # String | The account that owns the collection, e.g. `1618535966441231024`.
update_mask: 'update_mask_example' # String | The list of fields to update, separated by a comma, e.g. `authorized_query_domains,display_name`. Each field should be in snake case. For each field that you want to update, provide a corresponding value in the collection object containing the new value.
}
begin
# Update collection
result = api_instance.update_collection(collection_id, collection, opts)
p result
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->update_collection: #{e}"
end
This returns an Array which contains the response data, status code and headers.
<Array(, Integer, Hash)> update_collection_with_http_info(collection_id, collection, opts)
begin
# Update collection
data, status_code, headers = api_instance.update_collection_with_http_info(collection_id, collection, opts)
p status_code # => 2xx
p headers # => { ... }
p data # => <Collection>
rescue SajariAPIClient::ApiError => e
puts "Error when calling CollectionsApi->update_collection_with_http_info: #{e}"
end
Name | Type | Description | Notes |
---|---|---|---|
collection_id | String | The collection to update, e.g. `my-collection`. | |
collection | Collection | The details of the collection to update. | |
account_id | String | The account that owns the collection, e.g. `1618535966441231024`. | [optional] |
update_mask | String | The list of fields to update, separated by a comma, e.g. `authorized_query_domains,display_name`. Each field should be in snake case. For each field that you want to update, provide a corresponding value in the collection object containing the new value. | [optional] |
- Content-Type: application/json
- Accept: application/json