search mobile facets autocomplete spellcheck crawler rankings weights synonyms analytics engage api customize documentation install setup technology content domains user history info home business cart chart contact email activate analyticsalt analytics autocomplete cart contact content crawling custom documentation domains email engage faceted history info install mobile person querybuilder search setup spellcheck synonyms weights engage_search_term engage_related_content engage_next_results engage_personalized_results engage_recent_results success add arrow-down arrow-left arrow-right arrow-up caret-down caret-left caret-right caret-up check close content conversions-small conversions details edit grid help small-info error live magento minus move photo pin plus preview refresh search settings small-home stat subtract text trash unpin wordpress x alert case_deflection advanced-permissions keyword-detection predictive-ai sso

Search

Want to start with the basics? Give our Search Guide a read.


You can run the example requests on your local machine and see the responses in real-time.


The Search end-point allows you to search over, facet and filter your data. Any operation within your application that enables search over your documents will do so using this end-point. It is essential! You can use your Public Search Key or your Private API Key to query the Search end-point. In most cases, you will want to use the Public Search Key, as it is scoped to only access public-friendly parameters.

The Search API Reference is split into three different parts:

Search Responses

Upon a successful API request to the Search end-point, you will return meta and results keys. If there are any errors processing your query, a 400 response will be returned.

The results key will always be present in within a successful response. It will be an array of documents that match the requested query and filters. The returned fields of the document are specified by result_fields and can have a raw and/or snippet value. By default all fields are returned in the raw format.

The meta key will always be present in API response upon a successful query. It will be a JSON object containing information about the result set. It contains page, a unique BSON request_id and an array of possible warnings.

Page Argument Detail
current Page number that is in the results field.
total_pages Number of of results available.
total_results Number of results that match the query.
size Number of results per page.
// An example JSON payload from the search end-point.
{
  "meta": {
    "warnings": [],
    "page": {
      "current": number,
      "total_pages": number,
      "total_results": number,
      "size": number
    },
    "request_id": string
  },
  "results": [
    {
      key: {
        "raw": string
      },
      key: {
        "raw": string
      },
      key: {
        "raw": string
      }
    }
  ]
}    

The analytics/queries end-point responds to GET and POST requests. The payload you receive will include meta-data and results. There are two different end-points that you can query when making search requests. They both accept the same arguments. The key different is whether or not you would like to attach one or more query parameters.

Choose whichever is best for your use-case!

POST /api/as/v1/engines/{ENGINE_NAME}/search
GET /api/as/v1/engines/{ENGINE_NAME}/search
POST /api/as/v1/engines/{ENGINE_NAME}/multi_search
GET /api/as/v1/engines/{ENGINE_NAME}/multi_search
query
required
A string or number used to find related documents. To match all documents, use an empty string "".
search_fields
optional
A JSON object containing field names as keys and search field options as values. Defaults to searching over all text fields with equal importance. A valid weight can range from 0.0 to 1000.0; the default is 1.0.
View Example
boosts
optional
A JSON object containing field names as keys and boost options as values. Defaults to no boosting (i.e. the document score will only be based on the text matching score).
View Example
group
optional
A JSON object containing the field to group on and an optional size and sort argument. Defaults to no grouping, and the _group key will not be present in the returned documents.
View Example
result_fields
optional
A JSON object containing field names as keys and result field options as values. Defaults to returning raw values of all fields.
View Example
facets
optional
A JSON object containing field names as keys and facet options as values. Defaults to requesting no facets.
View Example
sort
optional
A JSON object or an array of JSON objects representing sort options: single key-value JSON object with the key being a field name or _score and the value being the sort direction (asc or desc). Defaults to sorting by descending score (i.e. { "_score": "desc"}).
View Example
page
optional
A JSON object with optional keys of size and current. Specifies the number of results per page and which page the API should return.
View Example
analytics
optional
A JSON object containing the key tags, an array of strings representing additional information you wish to track about the query. You can then filter queries by these tags in the Analytics tab of the App Search dashboard.
View Example

Performing a Single Search Query

Example - Performing a single query search.
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota"
}'

Example - Performing a single query search.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

try { Map<String, Object> response = client.search(engineName, query); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Performing a single query search.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

client .search(engineName, query) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Performing a single query search.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

begin puts client.search(engine_name, query) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Performing a single query search.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

try: print(client.search(engine_name, query)) except SwiftypeAppSearchError as e: print(e)

Example - Performing a single query search.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

client .search(query, {}) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Performing a Multiple Search Query

Example - Performing a multiple query search.
curl -X POST 'http://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/multi_search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "queries": [
    {"query": "toyota"},
    {"query": "jeep"}
  ]
}'

Example - Performing a multiple query search.
No Java example available, showing cURL
curl -X POST 'http://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/multi_search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "queries": [
    {"query": "toyota"},
    {"query": "jeep"}
  ]
}'

Example - Performing a multiple query search.
No Node example available, showing cURL
curl -X POST 'http://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/multi_search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "queries": [
    {"query": "toyota"},
    {"query": "jeep"}
  ]
}'

Example - Performing a multiple query search.
No Ruby example available, showing cURL
curl -X POST 'http://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/multi_search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "queries": [
    {"query": "toyota"},
    {"query": "jeep"}
  ]
}'

Example - Performing a multiple query search.
No Python example available, showing cURL
curl -X POST 'http://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/multi_search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "queries": [
    {"query": "toyota"},
    {"query": "jeep"}
  ]
}'

Example - Performing a multiple query search.
No Javascript example available, showing cURL
curl -X POST 'http://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/multi_search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "queries": [
    {"query": "toyota"},
    {"query": "jeep"}
  ]
}'

Search Fields

The search_fields parameter restricts a query to search only specific fields, and can also specify the importance of each field using weights. The value must be a JSON object where the keys are the text fields from your engine's schema and the values are nested JSON objects containing optional advanced search options. If the search_fields parameter is not given, all text fields will be searched by default with equal importance. The default search fields may be changed in the Relevance Tuning tab for your engine.

Specifying search_fields will result in faster query responses, especially for schemas with a large number of text fields.


If you provide a field in the search_fields parameter that is not a text field, it will be silently ignored.

Example - Specifying search_fields for a given query.
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "search_fields": {
    "make": {},
    "model": {},
    "category": {}
  },
  "query": "toyota"
}'

Example - Specifying search_fields for a given query.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> searchFields = new HashMap<>(); searchFields.put("make", Collections.emptyMap()); searchFields.put("model", Collections.emptyMap()); searchFields.put("category", Collections.emptyMap());

Map<String, Object> options = new HashMap<>(); options.put("search_fields", searchFields);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Specifying search_fields for a given query.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { search_fields: { make: {}, model: {}, category: {} } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Specifying search_fields for a given query.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { search_fields: { make: {}, model: {}, category: {} } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Specifying search_fields for a given query.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'search_fields': { 'make': {}, 'model': {}, 'category': {} } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Specifying search_fields for a given query.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { search_fields: { make: {}, model: {}, category: {} } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Weights

We have a visual dashboard guide for Weights, too. Read it here.


Some fields contain more important information than other fields (e.g. a query match in a blog post's title is more telling than a match in its body). The weight parameter allows you to change the impact a field's score has on the final document score. You can specify weights within a nested search_fields parameter.

If the search_fields parameter is not given, all fields will be given equal weight. The default search fields may be changed in the Relevance Tuning tab for your engine.

Example - Specifying weights to favor make, model, and category.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "search_fields": {
    "make": {
      "weight": 5
    },
    "model": {
      "weight": 10
    },
    "category": {}
  },
  "query": "toyota"
}'

Example - Specifying weights to favor make, model, and category.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Integer> make = new HashMap<>(); make.put("weight", 5);

Map<String, Integer> model = new HashMap<>(); model.put("weight", 10);

Map<String, Object> searchFields = new HashMap<>(); searchFields.put("make", make); searchFields.put("model", model); searchFields.put("category", Collections.emptyMap());

Map<String, Object> options = new HashMap<>(); options.put("search_fields", searchFields);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Specifying weights to favor make, model, and category.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { search_fields: { make: { weight: 5 }, model: { weight: 10 }, category: {} } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Specifying weights to favor make, model, and category.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { search_fields: { make: { weight: 5 }, model: { weight: 10 }, category: {} } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Specifying weights to favor make, model, and category.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'search_fields': { 'make': { 'weight': 5 }, 'model': { 'weight': 10 }, 'category': {} } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Specifying weights to favor make, model, and category.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { search_fields: { make: { weight: 5 }, model: { weight: 10 }, category: {} } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Boosts

We have a visual dashboard guide for Boosts, too. Read it here.


Boosts affect the score of the entire document. It is provided in the boosts parameter. The value should be JSON object where the keys are fields from your engines' schema, and the values are arrays of JSON objects specifying each boost's attributes.

Value Boosts

A value boost will boost the score of a document based on a direct value match. It is available on text, number, and date fields. A value boost is expressed in the following format.

type
required
Type of boost. For a value boost, this should be value.
value
required
The value to exact match on. Use an array to match on multiple values.
operation
optional
The arithmetic operation to perform (e.g. the final score will be {ORIGINAL DOC SCORE} + {factor} if the operation is add). Can be add or multiply; defaults to add.
factor
optional
Factor to alter the impact of a boost on the score of a document; defaults to 1.0.
Example - Applying a multiplicative value boost to cars that have a color value of "blue".
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "",
  "boosts": {
    "color": [
      {
        "type": "value",
        "value": "blue",
        "operation": "multiply",
        "factor": 10
      }
    ]
  }
}'

Example - Applying a multiplicative value boost to cars that have a color value of "blue".
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "";

Map<String, Object> colorValueBoost = new HashMap<>(); colorValueBoost.put("type", "value") colorValueBoost.put("value", "blue") colorValueBoost.put("operation", "multiply") colorValueBoost.put("factor", 10)

Map<String, Object> boosts = new HashMap<>(); boosts.put("color", Arrays.asList(colorValueBoost));

Map<String, Object> options = new HashMap<>(); options.put("boosts", boosts);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Applying a multiplicative value boost to cars that have a color value of "blue".
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = ''

const options = { boosts: { color: [ { type: 'value', value: 'blue', operation: 'multiply', factor: 10 } ] } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Applying a multiplicative value boost to cars that have a color value of "blue".
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = ''

options = { boosts: { color: [ { type: 'value', value: 'blue', operation: 'multiply', factor: 10 } ] } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Applying a multiplicative value boost to cars that have a color value of "blue".
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = ''

options = { 'boosts': { 'color': [ { 'type': 'value', 'value': 'blue', 'operation': 'multiply', 'factor': 10 } ] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Applying a multiplicative value boost to cars that have a color value of "blue".
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = ''

const options = { boosts: { color: [ { type: 'value', value: 'blue', operation: 'multiply', factor: 10 } ] } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

If there are multiple boost value matches (e.g. the tags field of a document is ["on sale", "child safe", "ludicrous speed"], and the value argument is ["on sale", "child safe"]), the document's overall score will only be boosted once. If you want the boost to be applied multiple times for each possible value match, use multiple value boosts, each boosting on a single value.

Functional Boosts

A functional boost will apply a function to the overall document score. It is only available on a number field. There are three types of functional boosts.

linearBoosts the overall document score by {FACTOR} * {FIELD_VALUE}.
exponentialBoosts the overall document score by {FACTOR} * e^{FIELD_VALUE})
logarithmicBoosts the overall document score by {FACTOR} * max(0.0001, log(max(1, {FIELD_VALUE})))

They are provided in the following format.

type
required
Type of boost. For a functional boost, this should be functional.
function
required
Type of function to calculate the boost value. Can be linear, exponential, or logarithmic.
operation
optional
The arithmetic operation to perform (e.g. the final score will be {ORIGINAL DOC SCORE} + {BOOST_VALUE} if the operation is add). Can be add or multiply; defaults to add.
factor
optional
Factor to alter the impact of a boost on the score of a document; defaults to 1.0.
Example - Applying a multiplicative functional boost on all document scores based on seats.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "boosts": {
    "seats": {
      "type": "functional",
      "function": "logarithmic",
      "operation": "multiply",
      "factor": 2
    }
  },
  "query": "toyota"
}'

Example - Applying a multiplicative functional boost on all document scores based on seats.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> seatsBoost = new HashMap<>(); seatsBoost.put("type", "functional") seatsBoost.put("function", "logarithmic") seatsBoost.put("operation", "multiply") seatsBoost.put("factor", 2)

Map<String, Object> boosts = new HashMap<>(); boosts.put("seats", seatsBoost);

Map<String, Object> options = new HashMap<>(); options.put("boosts", boosts);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Applying a multiplicative functional boost on all document scores based on seats.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { boosts: { seats: { type: 'functional', function: 'logarithmic', operation: 'multiply', factor: 2 } } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Applying a multiplicative functional boost on all document scores based on seats.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { boosts: { seats: { type: 'functional', function: 'logarithmic', operation: 'multiply', factor: 2 } } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Applying a multiplicative functional boost on all document scores based on seats.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'analytics': { 'tags': [ 'user', 'mobile', 'dealer' ] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Applying a multiplicative functional boost on all document scores based on seats.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { boosts: { seats: { type: 'functional', function: 'logarithmic', operation: 'multiply', factor: 2 } } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

If boosting on a document value that is an array, the first field value of each document will be used in the boost calculation.

Proximity Boosts

Instead of calculating the boost value based on the document value, a boost value can be calculated based on the difference between the document value and a specified value from the center parameter. This is available on number, date, and geolocation fields.

type
required
Type of boost. For a proximity boost, this should be proximity.
center
required
The mode of the distribution.
function
required
Type of function to calculate the boost value. Can be linear, exponential, or gaussian.
factor
optional
Factor to alter the impact of a boost on the score of a document; defaults to 1.0.
Example - Applying a proximity boost based on current_location to the San Francisco International Airport (coordinates of 37.6213, -122.3790).
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "boosts": {
    "current_location": {
      "type": "proximity",
      "function": "linear",
      "center": "37.6213, -122.3790",
      "factor": 8
    }
  },
  "query": "toyota"
}'

Example - Applying a proximity boost based on current_location to the San Francisco International Airport (coordinates of 37.6213, -122.3790).
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> currentLocationBoost = new HashMap<>(); currentLocationBoost.put("type", "proximity"); currentLocationBoost.put("function", "linear"); currentLocationBoost.put("center", "37.6213, -122.3790"); currentLocationBoost.put("factor", 8);

Map<String, Object> boosts = new HashMap<>(); boosts.put("current_location", currentLocationBoost);

Map<String, Object> options = new HashMap<>(); options.put("boosts", boosts);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Applying a proximity boost based on current_location to the San Francisco International Airport (coordinates of 37.6213, -122.3790).
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { boosts: { current_location: { type: 'proximity', function: 'linear', center: '37.6213, -122.3790', factor: 8 } } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Applying a proximity boost based on current_location to the San Francisco International Airport (coordinates of 37.6213, -122.3790).
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { boosts: { current_location: { type: 'proximity', function: 'linear', center: '37.6213, -122.3790', factor: 8 } } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Applying a proximity boost based on current_location to the San Francisco International Airport (coordinates of 37.6213, -122.3790).
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'boosts': { 'current_location': { 'type': 'proximity', 'function': 'linear', 'center': '37.6213, -122.3790', 'factor': 8 } } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Applying a proximity boost based on current_location to the San Francisco International Airport (coordinates of 37.6213, -122.3790).
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { boosts: { current_location: { type: 'proximity', function: 'linear', center: '37.6213, -122.3790', factor: 8 } } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

If boosting on a document value that is an array, the first field value of each document will be used in the boost calculation.

Group

Results can be grouped based on field if they share the exact same field. The most relevant document will have a key of _group with the value as an array of other documents that share the same value for a field. Documents in a _group key will not appear anywhere else in the search response. This is available on text, number, and date fields.

field
required
Field name to group results on.
size
optional
Number of results to be included in the _group key of the returned document. Can be between 1 and 10. Defaults to 10.
sort
optional
A JSON object containing the field name or _score as the key and the value as asc or desc. The default sort is by descending relevance.
Example - Searching for "child safe" and grouping on make of car.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "child safe",
  "result_fields": {
    "make": {
      "raw": {}
    },
    "model": {
      "raw": {}
    },
    "year": {
      "raw": {}
    },
    "tags": {
      "raw": {}
    }
  },
  "group": {
    "field": "make"
  }
}'
Example Response
{
  "meta": {
    # redacted
  },
  "results": [
    {
      "make": {
        "raw": "Toyota"
      },
      "model": {
        "raw": "Camry"
      },
      "year": {
        "raw": "2017"
      },
      "tags": {
        "raw": [
          "child safe",
          "power steering"
        ]
      },
      "id": {
        "raw": "66867a"
      },
      "_meta": {
        "score": 12.416615
      },
      "_group": [
        {
          "make": {
            "raw": "Toyota"
          },
          "model": {
            "raw": "4RUNNER"
          },
          "year": {
            "raw": "2017"
          },
          "tags": {
            "raw": [
              "child proof doors",
              "three wheel drive",
              "ludicrous speed",
              "premium gas",
              "red leather",
              "red seats"
            ]
          },
          "id": {
            "raw": "441376183"
          },
          "_meta": {
            "score": 1.2408893
          }
        }
      ]
    },
    {
      "make": {
        "raw": "Ford"
      },
      "model": {
        "raw": "Fiesta"
      },
      "year": {
        "raw": "2018"
      },
      "tags": {
        "raw": [
          "children approved",
          "fuel efficient"
        ]
      },
      "id": {
        "raw": "781226450"
      },
      "_meta": {
        "score": 0.021208191
      },
      "_group": []
    }
  ]
}

Example - Searching for "child safe" and grouping on make of car.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "child safe";

Map<String, Object> make = new HashMap<>(); make.put("raw", Collections.emptyMap()); Map<String, Object> model = new HashMap<>(); model.put("raw", Collections.emptyMap()); Map<String, Object> year = new HashMap<>(); year.put("raw", Collections.emptyMap()); Map<String, Object> tags = new HashMap<>(); tags.put("raw", Collections.emptyMap());

Map<String, Object> resultFields = new HashMap<>(); resultFields.put("make", make); resultFields.put("model", model); resultFields.put("year", year); resultFields.put("tags", tags);

Map<String, Object> group = new HashMap<>(); group.put("field", "make");

Map<String, Object> options = new HashMap<>(); options.put("result_fields", resultFields); options.put("group", group);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example Response
Map<String, Object>: {
  "meta": {
    // redacted
  },
  "results": [
    {
      "make": {
        "raw": "Toyota"
      },
      "model": {
        "raw": "Camry"
      },
      "year": {
        "raw": "2017"
      },
      "tags": {
        "raw": [
          "child safe",
          "power steering"
        ]
      },
      "id": {
        "raw": "66867a"
      },
      "_meta": {
        "score": 12.416615
      },
      "_group": [
        {
          "make": {
            "raw": "Toyota"
          },
          "model": {
            "raw": "4RUNNER"
          },
          "year": {
            "raw": "2017"
          },
          "tags": {
            "raw": [
              "child proof doors",
              "three wheel drive",
              "ludicrous speed",
              "premium gas",
              "red leather",
              "red seats"
            ]
          },
          "id": {
            "raw": "441376183"
          },
          "_meta": {
            "score": 1.2408893
          }
        }
      ]
    },
    {
      "make": {
        "raw": "Ford"
      },
      "model": {
        "raw": "Fiesta"
      },
      "year": {
        "raw": "2018"
      },
      "tags": {
        "raw": [
          "children approved",
          "fuel efficient"
        ]
      },
      "id": {
        "raw": "781226450"
      },
      "_meta": {
        "score": 0.021208191
      },
      "_group": []
    }
  ]
}

Example - Searching for "child safe" and grouping on make of car.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'child safe'

const options = { result_fields: { make: { raw: {} }, model: { raw: {} }, year: { raw: {} }, tags: { raw: {} } }, group: { field: 'make' } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example Response
{
  "meta": {
    // redacted
  },
  "results": [
    {
      "make": {
        "raw": "Toyota"
      },
      "model": {
        "raw": "Camry"
      },
      "year": {
        "raw": "2017"
      },
      "tags": {
        "raw": [
          "child safe",
          "power steering"
        ]
      },
      "id": {
        "raw": "66867a"
      },
      "_meta": {
        "score": 12.416615
      },
      "_group": [
        {
          "make": {
            "raw": "Toyota"
          },
          "model": {
            "raw": "4RUNNER"
          },
          "year": {
            "raw": "2017"
          },
          "tags": {
            "raw": [
              "child proof doors",
              "three wheel drive",
              "ludicrous speed",
              "premium gas",
              "red leather",
              "red seats"
            ]
          },
          "id": {
            "raw": "441376183"
          },
          "_meta": {
            "score": 1.2408893
          }
        }
      ]
    },
    {
      "make": {
        "raw": "Ford"
      },
      "model": {
        "raw": "Fiesta"
      },
      "year": {
        "raw": "2018"
      },
      "tags": {
        "raw": [
          "children approved",
          "fuel efficient"
        ]
      },
      "id": {
        "raw": "781226450"
      },
      "_meta": {
        "score": 0.021208191
      },
      "_group": []
    }
  ]
}

Example - Searching for "child safe" and grouping on make of car.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'child safe'

options = { result_fields: { make: { raw: {} }, model: { raw: {} }, year: { raw: {} }, tags: { raw: {} } }, group: { field: 'make' } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example Response
{
  'meta' => {
    # redacted
  },
  'results' => [
    {
      'make' => {
        'raw' => 'Toyota'
      },
      'model' => {
        'raw' => 'Camry'
      },
      'year' => {
        'raw' => '2017'
      },
      'tags' => {
        'raw' => [
          'child safe',
          'power steering'
        ]
      },
      'id' => {
        'raw' => '66867a'
      },
      '_meta' => {
        'score' => 12.416615
      },
      '_group' => [
        {
          'make' => {
            'raw' => 'Toyota'
          },
          'model' => {
            'raw' => '4RUNNER'
          },
          'year' => {
            'raw' => '2017'
          },
          'tags' => {
            'raw' => [
              'child proof doors',
              'three wheel drive',
              'ludicrous speed',
              'premium gas',
              'red leather',
              'red seats'
            ]
          },
          'id' => {
            'raw' => '441376183'
          },
          '_meta' => {
            'score' => 1.2408893
          }
        }
      ]
    },
    {
      'make' => {
        'raw' => 'Ford'
      },
      'model' => {
        'raw' => 'Fiesta'
      },
      'year' => {
        'raw' => '2018'
      },
      'tags' => {
        'raw' => [
          'children approved',
          'fuel efficient'
        ]
      },
      'id' => {
        'raw' => '781226450'
      },
      '_meta' => {
        'score' => 0.021208191
      },
      '_group' => []
    }
  ]
}

Example - Searching for "child safe" and grouping on make of car.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'child safe'

options = { 'result_fields': { 'make': { 'raw': {} }, 'model': { 'raw': {} }, 'year': { 'raw': {} }, 'tags': { 'raw': {} } }, 'group': { 'field': 'make' } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example Response
{
    'meta': {
        # redacted
    },
    'results': [
        {
            'make': {
                'raw': 'Toyota'
            },
            'model': {
                'raw': 'Camry'
            },
            'year': {
                'raw': '2017'
            },
            'tags': {
                'raw': [
                    'child safe',
                    'power steering'
                ]
            },
            'id': {
                'raw': '66867a'
            },
            '_meta': {
                'score': 12.416615
            },
            '_group': [
                {
                    'make': {
                        'raw': 'Toyota'
                    },
                    'model': {
                        'raw': '4RUNNER'
                    },
                    'year': {
                        'raw': '2017'
                    },
                    'tags': {
                        'raw': [
                            'child proof doors',
                            'three wheel drive',
                            'ludicrous speed',
                            'premium gas',
                            'red leather',
                            'red seats'
                        ]
                    },
                    'id': {
                        'raw': '441376183'
                    },
                    '_meta': {
                        'score': 1.2408893
                    }
                }
            ]
        },
        {
            'make': {
                'raw': 'Ford'
            },
            'model': {
                'raw': 'Fiesta'
            },
            'year': {
                'raw': '2018'
            },
            'tags': {
                'raw': [
                    'children approved',
                    'fuel efficient'
                ]
            },
            'id': {
                'raw': '781226450'
            },
            '_meta': {
                'score': 0.021208191
            },
            '_group': []
        }
    ]
}

Example - Searching for "child safe" and grouping on make of car.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'child safe'

const options = { result_fields: { make: { raw: {} }, model: { raw: {} }, year: { raw: {} }, tags: { raw: {} } }, group: { field: 'make' } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Example Response
ResultList {
  "rawResults": [
    {
      // redacted, same as ResultItem.data
    },
    {
      // redacted, same as ResultItem.data
    }
  ],
  "rawInfo": {
    "meta": {
      // redacted
    }
  },
  "results": [
    ResultItem {
      "data": {
        "make": {
          "raw": "Toyota"
        },
        "model": {
          "raw": "Camry"
        },
        "year": {
          "raw": "2017"
        },
        "tags": {
          "raw": [
            "child safe",
            "power steering"
          ]
        },
        "id": {
          "raw": "66867a"
        },
        "_meta": {
          "score": 12.416615
        },
        "_group": [
          {
            "make": {
              "raw": "Toyota"
            },
            "model": {
              "raw": "4RUNNER"
            },
            "year": {
              "raw": "2017"
            },
            "tags": {
              "raw": [
                "child proof doors",
                "three wheel drive",
                "ludicrous speed",
                "premium gas",
                "red leather",
                "red seats"
              ]
            },
            "id": {
              "raw": "441376183"
            },
            "_meta": {
              "score": 1.2408893
            }
          }
        ]
      }
    },
    ResultItem {
      "data": {
        "make": {
          "raw": "Ford"
        },
        "model": {
          "raw": "Fiesta"
        },
        "year": {
          "raw": "2018"
        },
        "tags": {
          "raw": [
            "children approved",
            "fuel efficient"
          ]
        },
        "id": {
          "raw": "781226450"
        },
        "_meta": {
          "score": 0.021208191
        },
        "_group": []
      }
    }
  ],
  "info": {
    "meta": {
      // redacted
    }
  }
}

Result Fields

Use the result_fields parameter to specify which fields to receive in the search response. The result_fields parameter must be a JSON object where the keys are the field names and the values are nested JSON objects containing the format of the returned field value.

If the result_fields parameter is not given, the API will return the raw values for all fields.

rawThe exact value that was indexed. Depending on the type of the field, this can be returned as either a string, number, or an array of strings/numbers.
snippetOnly available on the text field type. Will return the value of the field with highlights designated by <em> tags.

Raw Result Field

Requests the exact value that was indexed. Depending on the type of the field, this can be returned as either a string, number, or an array of strings/numbers. It is expressed in the following format.

size
optional
Length of the return value. Only can be used on text fields. Must be at least 20; defaults to the entire text field. If given for a different field type other than text, it will be silently ignored.
Example - Specifying result_fields of make and description.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "result_fields": {
    "make": {
      "raw": {}
    },
    "description": {
      "raw": {
        "size": 50
      }
    }
  }
}'
Example Response
{
  "meta": {
    # redacted
  },
  "results": [
    {
      "id": {
        "raw": "66867a"
      },
      "make": {
        "raw": "Toyota"
      },
      "_meta": {
        "score": 1.6835923
      }
    },
    {
      "description": {
        "raw": "A gorgeous three wheel drive that handles rapid"
      },
      "id": {
        "raw": "441376183"
      },
      "make": {
        "raw": "Toyota"
      },
      "_meta": {
        "score": 1.6835923
      }
    }
  ]
}

Example - Specifying result_fields of make and description.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> make = new HashMap<>(); make.put("raw", Collections.emptyMap());

Map<String, Integer> descriptionRaw = new HashMap<>(); descriptionRaw.put("size", 50); Map<String, Object> description = new HashMap<>(); description.put("raw", descriptionRaw);

Map<String, Object> resultFields = new HashMap<>(); resultFields.put("make", make); resultFields.put("description", description);

Map<String, Object> options = new HashMap<>(); options.put("result_fields", resultFields);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example Response
Map<String, Object>: {
  "meta": {
    // redacted
  },
  "results": [
    {
      "id": {
        "raw": "66867a"
      },
      "make": {
        "raw": "Toyota"
      },
      "_meta": {
        "score": 1.6835923
      }
    },
    {
      "description": {
        "raw": "A gorgeous three wheel drive that handles rapid"
      },
      "id": {
        "raw": "441376183"
      },
      "make": {
        "raw": "Toyota"
      },
      "_meta": {
        "score": 1.6835923
      }
    }
  ]
}

Example - Specifying result_fields of make and description.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { result_fields: { make: { raw: {} }, description: { raw: { size: 50 } } } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example Response
{
  "meta": {
    // redacted
  },
  "results": [
    {
      "id": {
        "raw": "66867a"
      },
      "make": {
        "raw": "Toyota"
      },
      "_meta": {
        "score": 1.6835923
      }
    },
    {
      "description": {
        "raw": "A gorgeous three wheel drive that handles rapid"
      },
      "id": {
        "raw": "441376183"
      },
      "make": {
        "raw": "Toyota"
      },
      "_meta": {
        "score": 1.6835923
      }
    }
  ]
}

Example - Specifying result_fields of make and description.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { result_fields: { make: { raw: {} }, description: { raw: { size: 50 } } } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example Response
{
  'meta' => {
    # redacted
  },
  'results' => [
    {
      'id' => {
        'raw' => '66867a'
      },
      'make' => {
        'raw' => 'Toyota'
      },
      '_meta' => {
        'score' => 1.6835923
      }
    },
    {
      'description' => {
        'raw' => 'A gorgeous three wheel drive that handles rapid'
      },
      'id' => {
        'raw' => '441376183'
      },
      'make' => {
        'raw' => 'Toyota'
      },
      '_meta' => {
        'score' => 1.6835923
      }
    }
  ]
}

Example - Specifying result_fields of make and description.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'result_fields': { 'make': { 'raw': {} }, 'description': { 'raw': { 'size': 50 } } } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example Response
{
    'meta': {
        # redacted
    },
    'results': [
        {
            'id': {
                'raw': '66867a'
            },
            'make': {
                'raw': 'Toyota'
            },
            '_meta': {
                'score': 1.6835923
            }
        },
        {
            'description': {
                'raw': 'A gorgeous three wheel drive that handles rapid'
            },
            'id': {
                'raw': '441376183'
            },
            'make': {
                'raw': 'Toyota'
            },
            '_meta': {
                'score': 1.6835923
            }
        }
    ]
}

Example - Specifying result_fields of make and description.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { result_fields: { make: { raw: {} }, description: { raw: { size: 50 } } } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Example Response
ResultList {
  "rawResults": [
    {
      // redacted, same as ResultItem.data
    },
    {
      // redacted, same as ResultItem.data
    }
  ],
  "rawInfo": {
    "meta": {
      // redacted
    }
  },
  "results": [
    ResultItem {
      "data": {
        "id": {
          "raw": "66867a"
        },
        "make": {
          "raw": "Toyota"
        },
        "_meta": {
          "score": 1.6835923
        }
      }
    },
    ResultItem {
      "data": {
        "description": {
          "raw": "A gorgeous three wheel drive that handles rapid"
        },
        "id": {
          "raw": "441376183"
        },
        "make": {
          "raw": "Toyota"
        },
        "_meta": {
          "score": 1.6835923
        }
      }
    }
  ],
  "info": {
    "meta": {
      // redacted
    }
  }
}

Snippet Result Field

Requests a snippet of a text field. The result will include the matched value wrapped in <em> tags, if one exists. Snippets are requested in the following format.

size
optional
Length of the snippet returned. Must be at least 25; defaults to 100.
fallback
optional
Boolean that specifies whether to return the raw text field if no snippet is found.
Example - Specifying result_fields of make, color, description, and tags.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "red",
  "result_fields": {
    "make": {
      "snippet": {
        "size": 20,
        "fallback": true
      }
    },
    "color": {
      "raw": {},
      "snippet": {
        "size": 20
      }
    },
    "description": {
      "raw": {
        "size": 200
      },
      "snippet": {
        "size": 100
      }
    },
    "tags": {
      "raw" : {},
      "snippet": {
        "size": 20,
        "fallback": true
      }
    }
  }
}'
Example Response
{
  "meta": {
    # redacted
  },
  "results": [
    {
      "color": {
        "raw": "blue",
        "snippet": null
      },
      "tags": {
        "raw": [
          "child proof doors",
          "three wheel drive",
          "ludicrous speed",
          "premium gas",
          "red leather",
          "red seats"
        ],
        "snippet": "<em>red</em> leather"
      },
      "description": {
        "raw": "A gorgeous three wheel drive that handles rapid stops, highway speeding, and cruising through red stop signs with ease.",
        "snippet": "rapid stops, highwayspeeding, and cruising through <em>red</em> stop signs with ease."
      },
      "id": {
        "raw": "441376183"
      },
      "make": {
        "snippet": "Toyota"
      },
      "_meta": {
        "score": 1.849434
      }
    },
    {
      "color": {
        "raw": "red",
        "snippet": "<em>red</em>"
      },
      "tags": {
        "raw": [
          "children approved",
          "fuel efficient"
        ],
        "snippet": null
      },
      "description": {
        "raw": "For when you want to party. Fiesta means \"festival\" or \"party\" in Spanish. Who wants a car that is a party pooper?",
        "snippet": null
      },
      "id": {
        "raw": "781226450"
      },
      "make": {
        "snippet": "Ford"
      },
      "_meta": {
        "score": 0.7335893
      }
    }
  ]
}

Example - Specifying result_fields of make, color, description, and tags.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "red";

Map<String, Object> makeSnippet = new HashMap<>(); makeSnippet.put("size", 20); makeSnippet.put("fallback", true); Map<String, Object> make = new HashMap<>(); make.put("snippet", makeSnippet);

Map<String, Object> colorSnippet = new HashMap<>(); colorSnippet.put("size", 20); Map<String, Object> color = new HashMap<>(); color.put("snippet", colorSnippet); color.put("raw", Collections.emptyMap());

Map<String, Integer> descriptionRaw = new HashMap<>(); descriptionRaw.put("size", 200); Map<String, Integer> descriptionSnippet = new HashMap<>(); descriptionSnippet.put("size", 100); Map<String, Object> description = new HashMap<>(); description.put("raw", descriptionRaw); description.put("snippet", descriptionSnippet);

Map<String, Object> tagsSnippet = new HashMap<>(); tagsSnippet.put("size", 20); tagsSnippet.put("fallback", true); Map<String, Object> tags = new HashMap<>(); tags.put("raw", Collections.emptyMap()); tags.put("snippet", tagsSnippet);

Map<String, Object> resultFields = new HashMap<>(); resultFields.put("make", make); resultFields.put("color", color); resultFields.put("description", description); resultFields.put("tags", tags);

Map<String, Object> options = new HashMap<>(); options.put("result_fields", resultFields);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example Response
Map<String, Object>: {
  "meta": {
    // redacted
  },
  "results": [
    {
      "color": {
        "raw": "blue",
        "snippet": null
      },
      "tags": {
        "raw": [
          "child proof doors",
          "three wheel drive",
          "ludicrous speed",
          "premium gas",
          "red leather",
          "red seats"
        ],
        "snippet": "<em>red</em> leather"
      },
      "description": {
        "raw": "A gorgeous three wheel drive that handles rapid stops, highway speeding, and cruising through red stop signs with ease.",
        "snippet": "rapid stops, highway speeding, and cruising through <em>red</em> stop signs with ease."
      },
      "id": {
        "raw": "441376183"
      },
      "make": {
        "snippet": "Toyota"
      },
      "_meta": {
        "score": 1.849434
      }
    },
    {
      "color": {
        "raw": "red",
        "snippet": "<em>red</em>"
      },
      "tags": {
        "raw": [
          "children approved",
          "fuel efficient"
        ],
        "snippet": null
      },
      "description": {
        "raw": "For when you want to party. Fiesta means &quot;festival&quot; or &quot;party&quot; in Spanish. Who wants a car that is a party pooper?",
        "snippet": null
      },
      "id": {
        "raw": "781226450"
      },
      "make": {
        "snippet": "Ford"
      },
      "_meta": {
        "score": 0.7335893
      }
    }
  ]
}

Example - Specifying result_fields of make, color, description, and tags.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'red'

const options = { result_fields: { make: { snippet: { size: 20, fallback: true } }, color: { raw: {}, snippet: { size: 20 } }, description: { raw: { size: 200 }, snippet: { size: 100 } }, tags: { raw: {}, snippet: { size: 20, fallback: true } } } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example Response
{
  "meta": {
    // redacted
  },
  "results": [
    {
      "color": {
        "raw": "blue",
        "snippet": null
      },
      "tags": {
        "raw": [
          "child proof doors",
          "three wheel drive",
          "ludicrous speed",
          "premium gas",
          "red leather",
          "red seats"
        ],
        "snippet": "<em>red</em> leather"
      },
      "description": {
        "raw": "A gorgeous three wheel drive that handles rapid stops, highway speeding, and cruising through red stop signs with ease.",
        "snippet": "rapid stops, highway speeding, and cruising through <em>red</em> stop signs with ease."
      },
      "id": {
        "raw": "441376183"
      },
      "make": {
        "snippet": "Toyota"
      },
      "_meta": {
        "score": 1.849434
      }
    },
    {
      "color": {
        "raw": "red",
        "snippet": "<em>red</em>"
      },
      "tags": {
        "raw": [
          "children approved",
          "fuel efficient"
        ],
        "snippet": null
      },
      "description": {
        "raw": "For when you want to party. Fiesta means &quot;festival&quot; or &quot;party&quot; in Spanish. Who wants a car that is a party pooper?",
        "snippet": null
      },
      "id": {
        "raw": "781226450"
      },
      "make": {
        "snippet": "Ford"
      },
      "_meta": {
        "score": 0.7335893
      }
    }
  ]
}

Example - Specifying result_fields of make, color, description, and tags.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'red'

options = { result_fields: { make: { snippet: { size: 20, fallback: true } }, color: { raw: {}, snippet: { size: 20 } }, description: { raw: { size: 200 }, snippet: { size: 100 } }, tags: { raw: {}, snippet: { size: 20, fallback: true } } } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example Response
{
  'meta' => {
    # redacted
  },
  'results' => [
    {
      'color' => {
        'raw' => 'blue',
        'snippet' => null
      },
      'tags' => {
        'raw' => [
          'child proof doors',
          'three wheel drive',
          'ludicrous speed',
          'premium gas',
          'red leather',
          'red seats'
        ],
        'snippet' => '<em>red</em> leather'
      },
      'description' => {
        'raw' => 'A gorgeous three wheel drive that handles rapid stops, highway speeding, and cruising through red stop signs with ease.',
        'snippet' => 'rapid stops, highway speeding, and cruising through <em>red</em> stop signs with ease.'
      },
      'id' => {
        'raw' => '441376183'
      },
      'make' => {
        'snippet' => 'Toyota'
      },
      '_meta' => {
        'score' => 1.849434
      }
    },
    {
      'color' => {
        'raw' => 'red',
        'snippet' => '<em>red</em>'
      },
      'tags' => {
        'raw' => [
          'children approved',
          'fuel efficient'
        ],
        'snippet' => null
      },
      'description' => {
        'raw' => 'For when you want to party. Fiesta means "festival" or "party" in Spanish. Who wants a car that is a party pooper?',
        'snippet' => null
      },
      'id' => {
        'raw' => '781226450'
      },
      'make' => {
        'snippet' => 'Ford'
      },
      '_meta' => {
        'score' => 0.7335893
      }
    }
  ]
}

Example - Specifying result_fields of make, color, description, and tags.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'red'

options = { 'result_fields': { 'make': { 'snippet': { 'size': 20, 'fallback': True } }, 'color': { 'raw': {}, 'snippet': { 'size': 20 } }, 'description': { 'raw': { 'size': 200 }, 'snippet': { 'size': 100 } }, 'tags': { 'raw': {}, 'snippet': { 'size': 20, 'fallback': True } } } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example Response
{
    'meta': {
        # redacted
    },
    'results': [
        {
            'color': {
                'raw': 'blue',
                'snippet': None
            },
            'tags': {
                'raw': [
                    'child proof doors',
                    'three wheel drive',
                    'ludicrous speed',
                    'premium gas',
                    'red leather',
                    'red seats'
                ],
                'snippet': '<em>red</em> leather'
            },
            'description': {
                'raw': 'A gorgeous three wheel drive that handles rapid stops, highway speeding, and cruising through red stop signs with ease.',
                'snippet': 'rapid stops, highway speeding, and cruising through <em>red</em> stop signs with ease.'
            },
            'id': {
                'raw': '441376183'
            },
            'make': {
                'snippet': 'Toyota'
            },
            '_meta': {
                'score': 1.849434
            }
        },
        {
            'color': {
                'raw': 'red',
                'snippet': '<em>red</em>'
            },
            'tags': {
                'raw': [
                    'children approved',
                    'fuel efficient'
                ],
                'snippet': None
            },
            'description': {
                'raw': 'For when you want to party. Fiesta means &#39;festival&#39; or &#39;party&#39; in Spanish. Who wants a car that is a party pooper?',
                'snippet': None
            },
            'id': {
                'raw': '781226450'
            },
            'make': {
                'snippet': 'Ford'
            },
            '_meta': {
                'score': 0.7335893
            }
        }
    ]
}

Example - Specifying result_fields of make, color, description, and tags.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'red'

const options = { result_fields: { make: { snippet: { size: 20, fallback: true } }, color: { raw: {}, snippet: { size: 20 } }, description: { raw: { size: 200 }, snippet: { size: 100 } }, tags: { raw: {}, snippet: { size: 20, fallback: true } } } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Example Response
ResultList {
  "rawResults": [
    {
      // redacted, same as ResultItem.data
    },
    {
      // redacted, same as ResultItem.data
    }
  ],
  "rawInfo": {
    "meta": {
      // redacted
    }
  },
  "results": [
    ResultItem {
      "data": {
        "color": {
          "raw": "blue",
          "snippet": null
        },
        "tags": {
          "raw": [
            "child proof doors",
            "three wheel drive",
            "ludicrous speed",
            "premium gas",
            "red leather",
            "red seats"
          ],
          "snippet": "<em>red</em> leather"
        },
        "description": {
          "raw": "A gorgeous three wheel drive that handles rapid stops, highway speeding, and cruising through red stop signs with ease.",
          "snippet": "rapid stops, highway speeding, and cruising through <em>red</em> stop signs with ease."
        },
        "id": {
          "raw": "441376183"
        },
        "make": {
          "snippet": "Toyota"
        },
        "_meta": {
          "score": 1.849434
        }
      }
    },
    ResultItem {
      "data": {
        "color": {
          "raw": "red",
          "snippet": "<em>red</em>"
        },
        "tags": {
          "raw": [
            "children approved",
            "fuel efficient"
          ],
          "snippet": null
        },
        "description": {
          "raw": "For when you want to party. Fiesta means &quot;festival&quot; or &quot;party&quot; in Spanish. Who wants a car that is a party pooper?",
          "snippet": null
        },
        "id": {
          "raw": "781226450"
        },
        "make": {
          "snippet": "Ford"
        },
        "_meta": {
          "score": 0.7335893
        }
      }
    }
  ],
  "info": {
    "meta": {
      // redacted
    }
  }
}

Snippets in API Response

If requesting a snippet on a non-text field or if there is no match for your query, the snippet field will be null.

Snippets on an array value will return the first match, or null (as shown in the tags field for the document with an id of "441376183"). There is no fallback support.

Facets

We have a conceptual guide for facets, too. Read it here.


A facet allows you to define a query and a schema field key in order to receive counts on your different fields alongside the search results. For example, if you have a field for color you can define a query then use facets to see how many of those field values are returned.

Understanding the request structure is the key to wielding facets.

{
  "query": string,
  "facets": {
    string: [
      {
        "type": string,
        ...
      }
    ]
  }
}
query
required
Each request is considered a query against your engine. The query provides scope for the facet.
facets
required
The facet key opens up the object where you define your schema field, then parameterize it within its array.
field key
required
The field from your schema to which you would like to apply your facet
type
required
Either a value (view) or range (view) style facet.

Value Facet

A value facet provides the counts of each value for a field. When faceting on a field that contains an array of values, each unique value in the array will be included in the response.

A document value of ["green", "blue", "green"] will only count the values "green" and "blue" once.
type
required
Type of facet, in this case it will be value.
size
optional
How many facets would you like to return? Can be between 1 and 250. 10 facets is the default.
sort
optional
JSON object where the key is either count or value and the value is asc or desc. The default is sorting by descending count.
Example - Getting the top five colors of vehicles matching the query "toyota".
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "facets": {
    "color": [
      {
        "type": "value",
        "sort": { "count": "desc" },
        "size": 5
      }
    ]
  }
}'
Example Response
{
  "meta": {
    "page": {
      "current": 1,
      "total_pages": 3,
      "total_results": 25,
      "size": 10
    },
    "request_id": "b052faa06792f1874808ddbc8805a52c"
  },
  "results": [
    # redacted
  ],
  "facets": {
    "color": [
      {
        "type": "value",
        "data": [
          {
            "value": "blue",
            "count": 5
          },
          {
            "value": "black",
            "count": 4
          },
          {
            "value": "red",
            "count": 2
          },
          {
            "value": "green",
            "count": 2
          },
          {
            "value": "beige",
            "count": 1
          }
        ]
      }
    ]
  }
}

Example - Getting the top five colors of vehicles matching the query "toyota".
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> sort = new HashMap<>(); sort.put("count", "desc");

Map<String, Object> colorFacet = new HashMap<>(); colorFacet.put("type", "value"); colorFacet.put("sort", sort); colorFacet.put("size", 5);

Map<String, Object> facets = new HashMap<>(); facets.put("color", Arrays.asList(colorFacet));

Map<String, Object> options = new HashMap<>(); options.put("facets", facets);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example Response
Map<String, Object>: {
  "meta": {
    "page": {
      "current": 1,
      "total_pages": 3,
      "total_results": 25,
      "size": 10
    },
    "request_id": "b052faa06792f1874808ddbc8805a52c"
  },
  "results": [
    // redacted
  ],
  "facets": {
    "color": [
      {
        "type": "value",
        "data": [
          {
            "value": "blue",
            "count": 5
          },
          {
            "value": "black",
            "count": 4
          },
          {
            "value": "red",
            "count": 2
          },
          {
            "value": "green",
            "count": 2
          },
          {
            "value": "beige",
            "count": 1
          }
        ]
      }
    ]
  }
}

Example - Getting the top five colors of vehicles matching the query "toyota".
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { facets: { color: [ { type: 'value', sort: { count: 'desc' }, size: 5 } ] } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example Response
{
  "meta": {
    "page": {
      "current": 1,
      "total_pages": 3,
      "total_results": 25,
      "size": 10
    },
    "request_id": "b052faa06792f1874808ddbc8805a52c"
  },
  "results": [
    // redacted
  ],
  "facets": {
    "color": [
      {
        "type": "value",
        "data": [
          {
            "value": "blue",
            "count": 5
          },
          {
            "value": "black",
            "count": 4
          },
          {
            "value": "red",
            "count": 2
          },
          {
            "value": "green",
            "count": 2
          },
          {
            "value": "beige",
            "count": 1
          }
        ]
      }
    ]
  }
}

Example - Getting the top five colors of vehicles matching the query "toyota".
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { facets: { color: [ { type: 'value', sort: { count: 'desc' }, size: 5 } ] } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example Response
{
  'meta' => {
    'page' => {
      'current' => 1,
      'total_pages' => 3,
      'total_results' => 25,
      'size' => 10
    },
    'request_id' => 'b052faa06792f1874808ddbc8805a52c'
  },
  'results' => [
    # redacted
  ],
  'facets' => {
    'color' => [
      {
        'type' => 'value',
        'data' => [
          {
            'value' => 'blue',
            'count' => 5
          },
          {
            'value' => 'black',
            'count' => 4
          },
          {
            'value' => 'red',
            'count' => 2
          },
          {
            'value' => 'green',
            'count' => 2
          },
          {
            'value' => 'beige',
            'count' => 1
          }
        ]
      }
    ]
  }
}

Example - Getting the top five colors of vehicles matching the query "toyota".
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'facets': { 'color': [ { 'type': 'value', 'sort': {'count': 'desc'}, 'size': 5 } ] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example Response
{
    'meta': {
        'page': {
            'current': 1,
            'total_pages': 3,
            'total_results': 25,
            'size': 10
        },
        'request_id': 'b052faa06792f1874808ddbc8805a52c'
    },
    'results': [
        # redacted
    ],
    'facets': {
        'color': [
            {
                'type': 'value',
                'data': [
                    {
                        'value': 'blue',
                        'count': 5
                    },
                    {
                        'value': 'black',
                        'count': 4
                    },
                    {
                        'value': 'red',
                        'count': 2
                    },
                    {
                        'value': 'green',
                        'count': 2
                    },
                    {
                        'value': 'beige',
                        'count': 1
                    }
                ]
            }
        ]
    }
}

Example - Getting the top five colors of vehicles matching the query "toyota".
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { facets: { color: [ { type: 'value', sort: { count: 'desc' }, size: 5 } ] } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Example Response
ResultList {
  "rawResults": [
    // redacted
  ],
  "rawInfo": {
    // redacted, same as ResultList.info
  },
  "results": [
    // redacted
  ],
  "info": {
    "meta": {
      "warnings": [],
      "page": {
        "current": 1,
        "total_pages": 1,
        "total_results": 2,
        "size": 10
      },
      "request_id": "f039b12b767d1aaa0e7aea7b33d7871c"
    },
    "facets": {
      "color": [
        {
          "type": "value",
          "data": [
            {
              "value": "blue",
              "count": 1
            }
          ]
        }
      ]
    }
  }
}

Range Facet

The range facet is available on number and geolocation fields. It returns counts of documents within the provided ranges.

A document value of [1, 3, 8, 10] will only be counted once per bucket if, for example, the given buckets are { "from": 1, "to": 5 } and { "from": 5, "to" 10 }.
from
optional
Inclusive lower bound of the range. Is required if to is not given.
to
optional
Exclusive upper bound of the range. Is required if from is not given.
name
optional
Name given to the range.
Range Facet on a Number Field
type
required
Type of facet, in this case it will be range.
ranges
required
An array of range objects. The objects must contain a to or from key. from is inclusive and to is exclusive.
Example - Getting the top ten colors of vehicles matching the query "toyota".
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "facets": {
    "daily_rate": [
      {
        "type": "range",
        "ranges": [
          { "from": 50, "to": 100 },
          { "from": 100, "to": 150 }
        ]
      }
    ]
  }
}'
Example Response
{
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 2,
      "size": 10
    },
    "request_id": "f8b005f719c6a34de76f92968190e308"
  },
  "results": [
    # redacted
  ],
  "facets": {
    "daily_rate": [
      {
        "type": "range",
        "data": [
          {
            "to": 100,
            "from": 50,
            "count": 7
          },
          {
            "to": 150,
            "from": 100,
            "count": 9
          }
        ]
      }
    ]
  }
}

Example - Getting the top ten colors of vehicles matching the query "toyota".
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> range1 = new HashMap<>(); range1.put("from", 50); range1.put("to", 100); Map<String, Object> range2 = new HashMap<>(); range2.put("from", 100); range2.put("to", 150);

Map<String, Object> dailyRateFacet = new HashMap<>(); dailyRateFacet.put("type", "range"); dailyRateFacet.put("ranges", Arrays.asList(range1, range2));

Map<String, Object> facets = new HashMap<>(); facets.put("daily_rate", Arrays.asList(dailyRateFacet));

Map<String, Object> options = new HashMap<>(); options.put("facets", facets);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example Response
Map<String, Object>: {
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 2,
      "size": 10
    },
    "request_id": "f8b005f719c6a34de76f92968190e308"
  },
  "results": [
    // redacted
  ],
  "facets": {
    "daily_rate": [
      {
        "type": "range",
        "data": [
          {
            "to": 100,
            "from": 50,
            "count": 7
          },
          {
            "to": 150,
            "from": 100,
            "count": 9
          }
        ]
      }
    ]
  }
}

Example - Getting the top ten colors of vehicles matching the query "toyota".
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { facets: { daily_rate: [ { type: 'range', ranges: [ { from: 50, to: 100 }, { from: 100, to: 150 } ] } ] } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example Response
{
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 2,
      "size": 10
    },
    "request_id": "f8b005f719c6a34de76f92968190e308"
  },
  "results": [
    // redacted
  ],
  "facets": {
    "daily_rate": [
      {
        "type": "range",
        "data": [
          {
            "to": 100,
            "from": 50,
            "count": 7
          },
          {
            "to": 150,
            "from": 100,
            "count": 9
          }
        ]
      }
    ]
  }
}

Example - Getting the top ten colors of vehicles matching the query "toyota".
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota' options = { facets: { daily_rate: [ { type: 'range', ranges: [ { from: 50, to: 100 }, { from: 100, to: 150 } ] } ] } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example Response
{
  'meta' => {
    'warnings' => [],
    'page' => {
      'current' => 1,
      'total_pages' => 1,
      'total_results' => 2,
      'size' => 10
    },
    'request_id' => 'f8b005f719c6a34de76f92968190e308'
  },
  'results' => [
    # redacted
  ],
  'facets' => {
    'daily_rate' => [
      {
        'type' => 'range',
        'data' => [
          {
            'to' => 100,
            'from' => 50,
            'count' => 7
          },
          {
            'to' => 150,
            'from' => 100,
            'count' => 9
          }
        ]
      }
    ]
  }
}

Example - Getting the top ten colors of vehicles matching the query "toyota".
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'facets': { 'daily_rate': [ { 'type': 'range', 'ranges': [ {'from': 50, 'to': 100}, {'from': 100, 'to': 150} ] } ] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example Response
{
    'meta': {
        'warnings': [],
        'page': {
            'current': 1,
            'total_pages': 1,
            'total_results': 2,
            'size': 10
        },
        'request_id': 'f8b005f719c6a34de76f92968190e308'
    },
    'results': [
        # redacted
    ],
    'facets': {
        'daily_rate': [
            {
                'type': 'range',
                'data': [
                    {
                        'to': 100,
                        'from': 50,
                        'count': 7
                    },
                    {
                        'to': 150,
                        'from': 100,
                        'count': 9
                    }
                ]
            }
        ]
    }
}

Example - Getting the top ten colors of vehicles matching the query "toyota".
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { facets: { daily_rate: [ { type: 'range', ranges: [ { from: 50, to: 100 }, { from: 100, to: 150 } ] } ] } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Example Response
ResultList {
  "rawResults": [
    // redacted
  ],
  "rawInfo": {
    // redacted, same as ResultList.info
  },
  "results": [
    // redacted
  ],
  "info": {
    "meta": {
      "warnings": [],
      "page": {
        "current": 1,
        "total_pages": 1,
        "total_results": 2,
        "size": 10
      },
      "request_id": "ee7a34ce9383d2674df559e587d9ea4b"
    },
    "facets": {
      "daily_rate": [
        {
          "type": "range",
          "data": [
            {
              "to": 100,
              "from": 50,
              "count": 1
            },
            {
              "to": 150,
              "from": 100,
              "count": 0
            }
          ]
        }
      ]
    }
  }
}

Range Facet on a Geo Field
type
required
Type of facet, in this case it will be range.
ranges
required
An array of range objects. The objects must contain a to or from key. from is inclusive and to is exclusive.
center
required
The mode of the distribution as a string in "[latitude], [longitude]" format.
unit
required
The base unit of measurement: mm, cm, m (meters), km, in, ft, yd, or mi (mile).
Example - Getting the counts of vehicles within the provided ranges.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "",
  "facets": {
    "current_location": [
      {
        "type": "range",
        "center": "52.3760, 4.894",
        "unit": "m",
        "ranges": [
          { "from": 0, "to": 100000, "name": "close by" },
          { "from": 100000, "to": 300000 },
          { "from": 300000 }
        ]
      }
    ]
  }
}'
Example Response
{
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 3,
      "size": 10
    },
    "request_id": "a4a0cd0311c73d7292ceaa25a3c74a6d"
  },
  "results": [
    # redacted
  ],
  "facets": {
    "current_location": [
      {
        "type": "range",
        "data": [
          {
            "to": 100000,
            "from": 0,
            "count": 8,
            "name": "close by"
          },
          {
            "to": 300000,
            "from": 100000,
            "count": 3
          },
          {
            "from": 300000,
            "count": 2
          }
        ]
      }
    ]
  }
}

Example - Getting the counts of vehicles within the provided ranges.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "";

Map<String, Object> range1 = new HashMap<>(); range1.put("from", 0); range1.put("to", 100000); range1.put("name", "close by"); Map<String, Object> range2 = new HashMap<>(); range2.put("from", 100000); range2.put("to", 300000); Map<String, Object> range3 = new HashMap<>(); range3.put("from", 300000);

Map<String, Object> currentLocationFacet = new HashMap<>(); currentLocationFacet.put("type", "range"); currentLocationFacet.put("center", "52.3760, 4.894"); currentLocationFacet.put("unit", "m"); currentLocationFacet.put("ranges", Arrays.asList(range1, range2, range3));

Map<String, Object> facets = new HashMap<>(); facets.put("current_location", Arrays.asList(currentLocationFacet));

Map<String, Object> options = new HashMap<>(); options.put("facets", facets);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example Response
Map<String, Object>: {
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 3,
      "size": 10
    },
    "request_id": "a4a0cd0311c73d7292ceaa25a3c74a6d"
  },
  "results": [
    // redacted
  ],
  "facets": {
    "current_location": [
      {
        "type": "range",
        "data": [
          {
            "to": 100000,
            "from": 0,
            "count": 8,
            "name": "close by"
          },
          {
            "to": 300000,
            "from": 100000,
            "count": 3
          },
          {
            "from": 300000,
            "count": 2
          }
        ]
      }
    ]
  }
}

Example - Getting the counts of vehicles within the provided ranges.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = ''

const options = { facets: { current_location: [ { type: 'range', center: '52.3760, 4.894', unit: 'm', ranges: [ { from: 0, to: 100000, name: 'close by' }, { from: 100000, to: 300000 }, { from: 300000 } ] } ] } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example Response
{
  "meta": {
    "warnings": [],
    "page": {
      "current": 1,
      "total_pages": 1,
      "total_results": 3,
      "size": 10
    },
    "request_id": "a4a0cd0311c73d7292ceaa25a3c74a6d"
  },
  "results": [
    // redacted
  ],
  "facets": {
    "current_location": [
      {
        "type": "range",
        "data": [
          {
            "to": 100000,
            "from": 0,
            "count": 8,
            "name": "close by"
          },
          {
            "to": 300000,
            "from": 100000,
            "count": 3
          },
          {
            "from": 300000,
            "count": 2
          }
        ]
      }
    ]
  }
}

Example - Getting the counts of vehicles within the provided ranges.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = ''

options = { facets: { current_location: [ { type: 'range', center: '52.3760, 4.894', unit: 'm', ranges: [ { from: 0, to: 100_000, name: 'close by' }, { from: 100_000, to: 300_000 }, { from: 300_000 } ] } ] } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example Response
{
  'meta' => {
    'warnings' => [],
    'page' => {
      'current' => 1,
      'total_pages' => 1,
      'total_results' => 3,
      'size' => 10
    },
    'request_id' => 'a4a0cd0311c73d7292ceaa25a3c74a6d'
  },
  'results' => [
    # redacted
  ],
  'facets' => {
    'current_location' => [
      {
        'type' => 'range',
        'data' => [
          {
            'to' => 100_000,
            'from' => 0,
            'count' => 8,
            'name' => 'close by'
          },
          {
            'to' => 300_000,
            'from' => 100_000,
            'count' => 3
          },
          {
            'from' => 300_000,
            'count' => 2
          }
        ]
      }
    ]
  }
}

Example - Getting the counts of vehicles within the provided ranges.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = ''

options = { 'facets': { 'current_location': [ { 'type': 'range', 'center': '52.3760, 4.894', 'unit': 'm', 'ranges': [ {'from': 0, 'to': 100000, 'name': 'close by'}, {'from': 100000, 'to': 300000}, {'from': 300000} ] } ] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example Response
{
    'meta': {
        'warnings': [],
        'page': {
            'current': 1,
            'total_pages': 1,
            'total_results': 3,
            'size': 10
        },
        'request_id': 'a4a0cd0311c73d7292ceaa25a3c74a6d'
    },
    'results': [
        # redacted
    ],
    'facets': {
        'current_location': [
            {
                'type': 'range',
                'data': [
                    {
                        'to': 100000,
                        'from': 0,
                        'count': 8,
                        'name': 'close by'
                    },
                    {
                        'to': 300000,
                        'from': 100000,
                        'count': 3
                    },
                    {
                        'from': 300000,
                        'count': 2
                    }
                ]
            }
        ]
    }
}

Example - Getting the counts of vehicles within the provided ranges.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = ''

const options = { facets: { current_location: [ { type: 'range', center: '52.3760, 4.894', unit: 'm', ranges: [ { from: 0, to: 100000, name: 'close by' }, { from: 100000, to: 300000 }, { from: 300000 } ] } ] } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Example Response
ResultList {
  "rawResults": [
    // redacted
  ],
  "rawInfo": {
    // redacted, same as ResultList.info
  },
  "results": [
    // redacted
  ],
  "info": {
    "meta": {
      "warnings": [],
      "page": {
        "current": 1,
        "total_pages": 1,
        "total_results": 3,
        "size": 10
      },
      "request_id": "1a57eed39741cfd10bd3af7bb4964a4f"
    },
    "facets": {
      "current_location": [
        {
          "type": "range",
          "data": [
            {
              "to": 100000,
              "from": 0,
              "name": "close by",
              "count": 0
            },
            {
              "to": 300000,
              "from": 100000,
              "count": 0
            },
            {
              "from": 300000,
              "count": 2
            }
          ]
        }
      ]
    }
  }
}

Sort

The sort parameter allows you to sort your results in an order other than document score. The sort parameter is expressed as a JSON object containing the field name as the key and the value as asc or desc. A special sorting field name is available, _score, to order by relevance.

If a sort parameter is not given, results will be ordered by descending relevance.

Example - Sorting alphabetically by the make of the vehicle.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "sort": {
    "make": "desc"
  }
}'

Example - Sorting alphabetically by the make of the vehicle.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, String> sort = new HashMap<>(); sort.put("make", "desc");

Map<String, Object> options = new HashMap<>(); options.put("sort", sort);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Sorting alphabetically by the make of the vehicle.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { sort: { make: 'desc' } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Sorting alphabetically by the make of the vehicle.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { sort: { make: 'desc' } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Sorting alphabetically by the make of the vehicle.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = options = { 'sort': { 'make': 'desc' } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Sorting alphabetically by the make of the vehicle.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { sort: { make: 'desc' } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Sorting on Multiple Fields

More fields can be used to sort. Instead of a single JSON object sort parameter, use an array of JSON objects. Sorting is applied in the order it is declared in the request.

Example - Sorting by document score and tie-breaking by the make of the vehicle.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "sort": [
    { "_score": "desc" },
    { "make": "desc" }
  ]
}'

Example - Sorting by document score and tie-breaking by the make of the vehicle.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, String> sortByScore = new HashMap<>(); sortByScore.put("_score", "desc");

Map<String, String> sortByMake = new HashMap<>(); sortByMake.put("make", "desc");

Map<String, Object> options = new HashMap<>(); options.put("sort", Arrays.asList(sortByScore, sortByMake));

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Sorting by document score and tie-breaking by the make of the vehicle.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { sort: [ { _score: 'desc' }, { make: 'desc' } ] }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Sorting by document score and tie-breaking by the make of the vehicle.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { sort: [ { _score: 'desc' }, { make: 'desc' } ] }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Sorting by document score and tie-breaking by the make of the vehicle.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'sort': [ {'_score': 'desc'}, {'make': 'desc'} ] }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Sorting by document score and tie-breaking by the make of the vehicle.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { sort: [ { _score: 'desc' }, { make: 'desc' } ] }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Page

The page parameter is used to get the next set of results and/or limit the number of results returned.

size
optional
Number of results per page. Must be between 1 and 1,000; default to 10.
current
optional
Page number to return. Must be greater or equal to 1; defaults to 1.
Example - Getting the second page of results with a page size of 5. The API will return documents #5 through #10 by document score in the response.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "page": {
    "size": 5,
    "current": 2
  }
}'

Example - Getting the second page of results with a page size of 5. The API will return documents #5 through #10 by document score in the response.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> page = new HashMap<>(); page.put("size", 5); page.put("current", 2);

Map<String, Object> options = new HashMap<>(); options.put("page", page);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Getting the second page of results with a page size of 5. The API will return documents #5 through #10 by document score in the response.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { page: { size: 5, current: 2 } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Getting the second page of results with a page size of 5. The API will return documents #5 through #10 by document score in the response.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { page: { size: 5, current: 2 } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Getting the second page of results with a page size of 5. The API will return documents #5 through #10 by document score in the response.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'page': { 'size': 5, 'current': 2 } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Getting the second page of results with a page size of 5. The API will return documents #5 through #10 by document score in the response.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { page: { size: 5, current: 2 } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Analytics

The analytics parameter allows you to submit tags representing additional information you wish to track about a query. You can view and filter by these tags in the Analytics tab of the App Search dashboard.

tags
required
Array of strings representing the tags you'd like to apply to this query. You may submit up to 16 tags, and each may be up to 64 characters in length.
Example - Submitting a query with the analytics tags "user", "mobile", and "dealer".
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "analytics": {
    "tags": [
      "user",
      "mobile",
      "dealer"
    ]
  }
}'

Example - Submitting a query with the analytics tags "user", "mobile", and "dealer".
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> analytics = new HashMap<>(); analytics.put("tags", Arrays.asList("user", "mobile", "dealer"));

Map<String, Object> options = new HashMap<>(); options.put("analytics", analytics);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Submitting a query with the analytics tags "user", "mobile", and "dealer".
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { analytics: { tags: [ 'user', 'mobile', 'dealer' ] } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Submitting a query with the analytics tags "user", "mobile", and "dealer".
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { analytics: { tags: %w[ user mobile dealer ] } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Submitting a query with the analytics tags "user", "mobile", and "dealer".
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'analytics': { 'tags': [ 'user', 'mobile', 'dealer' ] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Submitting a query with the analytics tags "user", "mobile", and "dealer".
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { analytics: { tags: [ 'user', 'mobile', 'dealer' ] } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Filters

Filters allow you to restrict which documents are returned by applying conditions to the value of a certain field. These can be used to further narrow the result set that a query will match.

Value Filters

To only return documents that have a field equal to a specific value, use a value filter. It is available on text, number, and date fields. The value to match on can be either a single value or an array of values. An array of values doesn't have to be an exact match on the array of values in a document, but rather it's an array of values that the document value can be without being filtered out.

Example - Filtering results from querying "toyota" to only vehicles that have a "RAV4" or "4RUNNER" model.
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "filters" : {
    "model": ["RAV4", "4RUNNER"]
  }
}'

Example - Filtering results from querying "toyota" to only vehicles that have a "RAV4" or "4RUNNER" model.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> filters = new HashMap<>(); filters.put("model", Arrays.asList("RAV4", "4RUNNER"));

Map<String, Object> options = new HashMap<>(); options.put("filters", filters);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Filtering results from querying "toyota" to only vehicles that have a "RAV4" or "4RUNNER" model.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { filters: { model: ['RAV4', '4RUNNER'] } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Filtering results from querying "toyota" to only vehicles that have a "RAV4" or "4RUNNER" model.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { filters: { model: %w[RAV4 4RUNNER] } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Filtering results from querying "toyota" to only vehicles that have a "RAV4" or "4RUNNER" model.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'filters': { 'model': ['RAV4', '4RUNNER'] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Filtering results from querying "toyota" to only vehicles that have a "RAV4" or "4RUNNER" model.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { filters: { model: ['RAV4', '4RUNNER'] } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Range Filters

Range filters can be used to filter on a number or date field. The lower bound, from is inclusive and the upper bound, to, is exclusive.

Example - Filtering results to only vehicles that have a daily rate greater or equal to 60 and less than 80.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "filters": {
    "daily_rate": {
      "from": 60,
      "to": 80
    }
  }
}'

Example - Filtering results to only vehicles that have a daily rate greater or equal to 60 and less than 80.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> dailyRateFilter = new HashMap<>(); dailyRateFilter.put("from", 60); dailyRateFilter.put("to", 80);

Map<String, Object> filters = new HashMap<>(); filters.put("daily_rate", dailyRateFilter);

Map<String, Object> options = new HashMap<>(); options.put("filters", filters);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Filtering results to only vehicles that have a daily rate greater or equal to 60 and less than 80.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { filters: { daily_rate: { from: 60, to: 80 } } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Filtering results to only vehicles that have a daily rate greater or equal to 60 and less than 80.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { filters: { daily_rate: { from: 60, to: 80 } } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Filtering results to only vehicles that have a daily rate greater or equal to 60 and less than 80.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'filters': { 'daily_rate': { 'from': 60, 'to': 80 } } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Filtering results to only vehicles that have a daily rate greater or equal to 60 and less than 80.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { filters: { daily_rate: { from: 60, to: 80 } } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Geo Filters

geolocation fields can be filtered based on their proximity to a certain point. center must be in the format "latitude, longitude" and the unit may be mm, cm, m (meters), km, in, ft, yd, or mi (mile).

Example - Filtering results from querying "toyota" to only vehicles within three kilometers of San Francisco International Airport.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "filters": {
    "current_location": {
      "center": "52.3760, 4.894",
      "distance": 3,
      "unit": "km"
    }
  }
}'

Example - Filtering results from querying "toyota" to only vehicles within three kilometers of San Francisco International Airport.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, Object> currentLocationFilter = new HashMap<>(); currentLocationFilter.put("center", "52.3760, 4.894"); currentLocationFilter.put("distance", 3); currentLocationFilter.put("unit", "km");

Map<String, Object> filters = new HashMap<>(); filters.put("current_location", currentLocationFilter);

Map<String, Object> options = new HashMap<>(); options.put("filters", filters);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example - Filtering results from querying "toyota" to only vehicles within three kilometers of San Francisco International Airport.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { filters: { current_location: { center: '52.3760, 4.894', distance: 3, unit: 'km' } } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example - Filtering results from querying "toyota" to only vehicles within three kilometers of San Francisco International Airport.
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { filters: { current_location: { center: '52.3760, 4.894', distance: 3, unit: 'km' } } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example - Filtering results from querying "toyota" to only vehicles within three kilometers of San Francisco International Airport.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'filters': { 'current_location': { 'center': '52.3760, 4.894', 'distance': 3, 'unit': 'km' } } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example - Filtering results from querying "toyota" to only vehicles within three kilometers of San Francisco International Airport.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { filters: { current_location: { center: '52.3760, 4.894', distance: 3, unit: 'km' } } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Combining Filters

Certain search use cases require more than basic filtering. There are three boolean clauses that are supported to allow for more flexibility when searching.

anyat least one of the filters must match
allall of the filters must match
noneall of the filters must not match

The following query will find documents that match the query string "toyota" and meet the following criteria:

  • color is "blue"
  • status is "available"
  • drivetrain is "AWD" or category is "Full-Size SUV"
  • mileage_policy is not "limited"
Example
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "filters": {
    "all": [
      { "color": "blue" },
      { "status": "available" }
    ],
    "any": [
      { "drivetrain": "AWD" },
      { "category": "Full-Size SUV" }
    ],
    "none": [
      { "mileage_policy": "limited" }
    ]
  }
}'

Example
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, String> colorFilter = new HashMap<>(); colorFilter.put("color", "blue"); Map<String, String> statusFilter = new HashMap<>(); statusFilter.put("status", "available"); Map<String, String> drivetrainFilter = new HashMap<>(); drivetrainFilter.put("drivetrain", "AWD"); Map<String, String> categoryFilter = new HashMap<>(); categoryFilter.put("category", "Full-Size SUV"); Map<String, String> mileagePolicyFilter = new HashMap<>(); mileagePolicyFilter.put("mileage_policy", "limited");

Map<String, Object> filters = new HashMap<>(); filters.put("all", Arrays.asList(colorFilter, statusFilter)); filters.put("any", Arrays.asList(drivetrainFilter, categoryFilter)); filters.put("none", Arrays.asList(mileagePolicyFilter));

Map<String, Object> options = new HashMap<>(); options.put("filters", filters);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { filters: { all: [ { color: 'blue' }, { status: 'available' } ], any: [ { drivetrain: 'AWD' }, { category: 'Full-Size SUV' } ], none: [ { mileage_policy: 'limited' } ] } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { filters: { all: [ { color: 'blue' }, { status: 'available' } ], any: [ { drivetrain: 'AWD' }, { category: 'Full-Size SUV' } ], none: [ { mileage_policy: 'limited' } ] } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'filters': { 'all': [ {'color': 'blue'}, {'status': 'available'} ], 'any': [ {'drivetrain': 'AWD'}, {'category': 'Full-Size SUV'} ], 'none': [ {'mileage_policy': 'limited'} ] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { filters: { all: [ { color: 'blue' }, { status: 'available' } ], any: [ { drivetrain: 'AWD' }, { category: 'Full-Size SUV' } ], none: [ { mileage_policy: 'limited' } ] } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

If there is only one condition for any combination keyword clause, a single JSON object can be given. In the above example, the none key can have value of { "mileage_policy": "limited" } instead of [{ "mileage_policy": "limited" }] and have the same filtering behavior.

Nesting Filters

Clauses can be nested within each other to have even more expressive filtering. Any given filter can have at most 5 levels of nesting.

Example
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/rent-a-car/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-o5bk7qpaedd2xmcsavb1d8os' \
-d '{
  "query": "toyota",
  "filters": {
    "any": [
      {
        "all": [
          { "make": "Toyota" },
          { "model": "4RUNNER" }
        ]
      },
      {
        "all": [
          { "make": "Jeep" },
          { "model": "Grand Cherokee" }
        ]
      }
    ]
  }
}'

Example
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

Client client = new Client("host-2376rb", "search-o5bk7qpaedd2xmcsavb1d8os");

String engineName = "rent-a-car"; String query = "toyota";

Map<String, String> toyotaMakeFilter = new HashMap<>(); toyotaMakeFilter.put("make", "Toyota"); Map<String, String> toyotaModelFilter = new HashMap<>(); toyotaModelFilter.put("model", "4RUNNER"); Map<String, Object> allToyotaFilters = new HashMap<>(); allToyotaFilters.put("all", Arrays.asList(toyotaMakeFilter, toyotaModelFilter));

Map<String, String> jeepMakeFilters = new HashMap<>(); jeepMakeFilters.put("make", "Jeep"); Map<String, String> jeepModelFilters = new HashMap<>(); jeepModelFilters.put("model", "Grand Cherokee"); Map<String, Object> allJeepFilters = new HashMap<>(); allJeepFilters.put("all", Arrays.asList(jeepMakeFilters, jeepModelFilters));

Map<String, Object> filters = new HashMap<>(); filters.put("any", Arrays.asList(allToyotaFilters, allJeepFilters));

Map<String, Object> options = new HashMap<>(); options.put("filters", filters);

try { Map<String, Object> response = client.search(engineName, query, options); System.out.println(response); } catch (ClientException e) { System.out.println(e); }

Example
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

const client = new SwiftypeAppSearchClient('host-2376rb', 'search-o5bk7qpaedd2xmcsavb1d8os')

const engineName = 'rent-a-car' const query = 'toyota'

const options = { filters: { any: [ { all: [ { make: 'Toyota' }, { model: '4RUNNER' } ] }, { all: [ { make: 'Jeep' }, { model: 'Grand Cherokee' } ] } ] } }

client .search(engineName, query, options) .then(response => console.log(response)) .catch(error => console.log(error))

Example
require 'swiftype-app-search'

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = SwiftypeAppSearch::Client.new(host_identifier: host_identifier, api_key: api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { filters: { any: [ { all: [ { make: 'Toyota' }, { model: '4RUNNER' } ] }, { all: [ { make: 'Jeep' }, { model: 'Grand Cherokee' } ] } ] } }

begin puts client.search(engine_name, query, options) rescue SwiftypeAppSearch::ClientException => e puts e end

Example
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

host_identifier = 'host-2376rb' api_key = 'search-o5bk7qpaedd2xmcsavb1d8os' client = Client(host_identifier, api_key)

engine_name = 'rent-a-car' query = 'toyota'

options = { 'filters': { 'any': [ { 'all': [ {'make': 'Toyota'}, {'model': '4RUNNER'} ] }, { 'all': [ {'make': 'Jeep'}, {'model': 'Grand Cherokee'} ] } ] } }

try: print(client.search(engine_name, query, options)) except SwiftypeAppSearchError as e: print(e)

Example
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-o5bk7qpaedd2xmcsavb1d8os',
  engineName: 'rent-a-car'
})

const query = 'toyota'

const options = { filters: { any: [ { all: [ { make: 'Toyota' }, { model: '4RUNNER' } ] }, { all: [ { make: 'Jeep' }, { model: 'Grand Cherokee' } ] } ] } }

client .search(query, options) .then(function(response){ console.log(response) }) .catch(function(error){ console.log(error) })

Common Malformed API Requests

There are many ways that a query request can fail. The error message returned by the API will have detailed information regarding what should be changed to ensure a successful request and will return a 400 response.

ParameterConditions of when a 400 response will be returned by the API
queryIf the parameter is missing from the request.
If the parameter value is not a string or a number.
search_fieldsIf a requested search field does not exist in the current schema.
If a search field JSON object is malformed. It must be an empty JSON object or a JSON object with a weight key.
If all search fields are non text fields.
result_fieldsIf a result field requested does not exist in the current schema.
If a request field JSON object is malformed. It must be an empty JSON object or have keys of raw and/or snippet and a value of a JSON object optionally containing keys of size and fallback (if requesting a snippet).
If the requested raw size is less than 15.
If a size is requested for a non text field.
If the requested snippet size is not greater or equal to 20 and less than 1000.
If the fallback parameter for a snippet is not a boolean.
facetsIf the faceting field is not in the schema.
If the requested facets JSON object is malformed.
If a value facet is on a field type that is not text, number, or date.
If a range facet is on a field type that is not number, date, or geolocation.
If a range facet does not provide ranges in an acceptable format for the field type.
boostsIf the boosted field is not in the schema.
If the boost JSON object is malformed, missing required arguments, or has invalid values.
If a value boost is not on a field type that is not text, number, or date.
If a functional boost is on a field type that is not number.
If a proximity boost is on a field type that is not number, date, or geolocation.
sortIf the field used to sort is not in the schema and is not _score.
If the sort JSON object has more than one key.
pageIf the parameter is not a JSON object.
If the size argument is not greater than or equal to 1 and less than 1,000.
If the page argument is not greater than or equal to 1 and less than 500.

What's Next?

Search! Returning results is the tip of the iceberg. Now, you get to wield powerful tools to provide an excellent, fun and fluid experience. If you want to start polishing up how results appear, improving relevance and meeting business goals in the process, consider reading about Curations. If you want to see how your users search, consider diving into Analytics or Clickthrough.


Stuck? Looking for help? Contact Support!