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

Filters

Apply conditions to field values to filter results.

Type Value Filter Range Filter Geo Filter
text Yes No No
number Yes Yes No
date Yes Yes No
geolocation No No Yes

Value Filter

Return documents that contain a specific field value.

Available on text, number, and date fields.

query
required
Each request is considered a query against your engine. The query provides scope for the facet.
filters
required
The filters key opens up the object where you define the fields upon which to filter.
field key
required
The field from your schema upon which to apply your filter.
field value
required
The value upon which to filter. The value must be an exact match, even casing: True will not match on true.
Example - Filtering results for "parks" which are also world heritage sites.
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "parks",
  "filters" : {
    "world_heritage_site": [ "true" ]
  }
}'

Example - Filtering results for "parks" which are also world heritage sites.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

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

String engineName = "national-parks-demo"; String query = "parks";

Map<String, Object> filters = new HashMap<>(); filters.put("world_heritage_site", Arrays.asList("true"));

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 for "parks" which are also world heritage sites.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

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

const engineName = 'national-parks-demo' const query = 'parks'

const options = { filters: { world_heritage_site: ['true'] } }

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

Example - Filtering results for "parks" which are also world heritage sites.
require 'swiftype-app-search'

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

engine_name = 'national-parks-demo' query = 'parks'

options = { filters: { world_heritage_site: %w[true] } }

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

Example - Filtering results for "parks" which are also world heritage sites.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

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

engine_name = 'national-parks-demo' query = 'parks'

options = { 'filters': { 'world_heritage_site': ['true'] } }

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

Example - Filtering results for "parks" which are also world heritage sites.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
  engineName: 'national-parks-demo'
})

const query = 'parks'

const options = { filters: { world_heritage_site: ['true'] } }

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

Range Filter

Return documents over a range of dates or numbers.

Available on number or date fields.

query
required
Each request is considered a query against your engine. The query provides scope for the facet.
filters
required
The filters key opens up the object where you define the fields upon which to filter.
field key
required
The field from your schema upon which to apply your filter.
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.
Example - Filtering results to only national parks that have a their established_date between 1900 and 1950.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "park",
  "filters": {
    "date_established": {
      "from": "1900-01-01T12:00:00+00:00",
      "to": "1950-01-01T00:00:00+00:00"
    }
  }
}'

Example - Filtering results to only national parks that have a their established_date between 1900 and 1950.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

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

String engineName = "national-parks-demo"; String query = "everglade";

Map<String, Object> dateEstablishedFilter = new HashMap<>(); dateEstablishedFilter.put("from", "1900-01-01T12:00:00+00:00"); dateEstablishedFilter.put("to", "1950-01-01T00:00:00+00:00");

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

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 national parks that have a their established_date between 1900 and 1950.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

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

const engineName = 'national-parks-demo' const query = 'parks'

const options = { filters: { date_established: { from: '1900-01-01T12:00:00+00:00', to: '1950-01-01T00:00:00+00:00' } } }

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

Example - Filtering results to only national parks that have a their established_date between 1900 and 1950.
require 'swiftype-app-search'

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

engine_name = 'national-parks-demo' query = 'parks'

options = { filters: { date_established: { from: '1900-01-01T12:00:00+00:00', to: '1950-01-01T00:00:00+00:00' } } }

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

Example - Filtering results to only national parks that have a their established_date between 1900 and 1950.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

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

engine_name = 'national-parks-demo' query = 'parks'

options = { 'filters': { 'date_established': { 'from': '1900-01-01T12:00:00+00:00', 'to': '1950-01-01T00:00:00+00:00' } } }

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

Example - Filtering results to only national parks that have a their established_date between 1900 and 1950.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
  engineName: 'national-parks-demo'
})

const query = 'parks'

const options = { filters: { date_established: { from: '1900-01-01T12:00:00+00:00', to: '1950-01-01T00:00:00+00:00' } } }

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

Geo Filter

Return documents relative to their location.

query
required
Each request is considered a query against your engine. The query provides scope for the facet.
filters
required
The filters key opens up the object where you define the fields upon which to filter.
field key
required
The field from your schema upon which to apply your filter.
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 (miles).
distance
optional
A number representing the distance unit. Is required if from or to is not given.
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.
Example - Filtering results for "parks" to those within 300 kilometers of Elastic's San Francisco office.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "parks",
  "filters": {
    "location": {
      "center": "37.386483, -122.083842",
      "distance": 300,
      "unit": "km"
    }
  }
}'

Example - Filtering results for "parks" to those within 300 kilometers of Elastic's San Francisco office.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

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

String engineName = "national-parks-demo"; String query = "parks";

Map<String, Object> currentLocationFilter = new HashMap<>(); currentLocationFilter.put("center", "37.386483, -122.083842"); currentLocationFilter.put("distance", 300); currentLocationFilter.put("unit", "km");

Map<String, Object> filters = new HashMap<>(); filters.put("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 for "parks" to those within 300 kilometers of Elastic's San Francisco office.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

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

const engineName = 'national-parks-demo' const query = 'parks'

const options = { filters: { location: { center: '37.386483, -122.083842', distance: 300, unit: 'km' } } }

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

Example - Filtering results for "parks" to those within 300 kilometers of Elastic's San Francisco office.
require 'swiftype-app-search'

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

engine_name = 'national-parks-demo' query = 'parks'

options = { filters: { location: { center: '37.386483, -122.083842', distance: 300, unit: 'km' } } }

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

Example - Filtering results for "parks" to those within 300 kilometers of Elastic's San Francisco office.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

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

engine_name = 'national-parks-demo' query = 'parks'

options = { 'filters': { 'location': { 'center': '37.386483, -122.083842', 'distance': 300, 'unit': 'km' } } }

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

Example - Filtering results for "parks" to those within 300 kilometers of Elastic's San Francisco office.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
  engineName: 'national-parks-demo'
})

const query = 'parks'

const options = { filters: { location: { center: '37.386483, -122.083842', distance: 300, unit: 'km' } } }

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

Example - Filtering results for "parks" between 0 and 1000 metres from Elastic's San Francisco office.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "parks",
  "filters": {
    "location": {
      "center": "37.386483, -122.083842",
      "unit": "m",
      "from": 0,
      "to": 1000
    }
  }
}'

Example - Filtering results for "parks" between 0 and 1000 metres from Elastic's San Francisco office.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

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

String engineName = "national-parks-demo"; String query = "parks";

Map<String, Object> currentLocationFilter = new HashMap<>(); currentLocationFilter.put("center", "37.386483, -122.083842"); currentLocationFilter.put("unit", "m"); currentLocationFilter.put("from", "0"); currentLocationFilter.put("to", "1000");

Map<String, Object> filters = new HashMap<>(); filters.put("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 for "parks" between 0 and 1000 metres from Elastic's San Francisco office.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

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

const engineName = 'national-parks-demo' const query = 'parks'

const options = { filters: { location: { center: '37.386483, -122.083842', unit: 'm', from: '0', to: '1000' } } }

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

Example - Filtering results for "parks" between 0 and 1000 metres from Elastic's San Francisco office.
require 'swiftype-app-search'

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

engine_name = 'national-parks-demo' query = 'parks'

options = { filters: { location: { center: '37.386483, -122.083842', unit: 'm', from: '0', to: '1000' } } }

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

Example - Filtering results for "parks" between 0 and 1000 metres from Elastic's San Francisco office.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

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

engine_name = 'national-parks-demo' query = 'parks'

options = { 'filters': { 'location': { 'center': '37.386483, -122.083842', 'unit': 'm', 'from': '0', 'to': '1000' } } }

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

Example - Filtering results for "parks" between 0 and 1000 metres from Elastic's San Francisco office.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
  engineName: 'national-parks-demo'
})

const query = 'parks'

const options = { filters: { location: { center: '37.386483, -122.083842', unit: 'm', from: '0', to: '1000' } } }

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

Combining Filters

There are three boolean clauses that are supported to allow for more flexibility when searching.

anyAt least one of the filters must match. This functions as an OR condition.
allAll of the filters must match. This functions as an AND condition.
noneAll of the filters must not match. This functions as a NOT condition.
Example - Searching for "parks" which are in "California" and are "World Heritage Sites". They must be over 40000 acres or more than 500 square kilometers. The park can not be "Yosemite".
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "parks",
  "filters": {
    "all": [
      { "states": "California" },
      { "world_heritage_site": "true" }
    ],
    "any": [
      { "acres": { "from": 40000 } },
      { "square_km": { "from": 500 } }
    ],
    "none": [
      { "title": "Yosemite" }
    ]
  }
}'

Example - Searching for "parks" which are in "California" and are "World Heritage Sites". They must be over 40000 acres or more than 500 square kilometers. The park can not be "Yosemite".
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

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

String engineName = "national-parks-demo"; String query = "parks";

Map<String, Object> acresFilter = new HashMap<>(); acresFilter.put("from", 4000); Map<String, Object> kmFilter = new HashMap<>(); kmFilter.put("from", 500);

Map<String, String> statesFilter = new HashMap<>(); statesFilter.put("states", "California"); Map<String, String> heritageFilter = new HashMap<>(); heritageFilter.put("world_heritage_site", "true"); Map<String, String> acresFilter = new HashMap<>(); acresFilter.put("acres", acresFilter); Map<String, String> kmFilter = new HashMap<>(); kmFilter.put("square_km", kmFilter); Map<String, String> titleFilter = new HashMap<>(); titleFilter.put("title", "Yosemite");

Map<String, Object> filters = new HashMap<>(); filters.put("all", Arrays.asList(statesFilter, heritageFilter)); filters.put("any", Arrays.asList(acresFilter, kmFilter)); filters.put("none", Arrays.asList(titleFilter));

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 - Searching for "parks" which are in "California" and are "World Heritage Sites". They must be over 40000 acres or more than 500 square kilometers. The park can not be "Yosemite".
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

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

const engineName = 'national-parks-demo' const query = 'parks'

const options = { filters: { all: [ { states: 'California' }, { world_heritage_site: 'true' } ], any: [ { acres: { from: 40000 } }, { square_km: { from: 500 } } ], none: [ { title: 'yosemite' } ] } }

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

Example - Searching for "parks" which are in "California" and are "World Heritage Sites". They must be over 40000 acres or more than 500 square kilometers. The park can not be "Yosemite".
require 'swiftype-app-search'

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

engine_name = 'national-parks-demo' query = 'parks'

options = { filters: { all: [ { states: 'California' }, { world_heritage_site: 'true' } ], any: [ { acres: { from: 40000 } }, { square_km: { from: 500 } } ], none: [ { title: 'yosemite' } ] } }

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

Example - Searching for "parks" which are in "California" and are "World Heritage Sites". They must be over 40000 acres or more than 500 square kilometers. The park can not be "Yosemite".
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

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

engine_name = 'national-parks-demo' query = 'parks'

options = { 'filters': { 'all': [ {'states': 'California'}, {'world_heritage_site': 'true'} ], 'any': [ {'acres': 'from': 40000 }, {'square_km': 'from': 500} ], 'none': [ {'title': 'Yosemite'} ] } }

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

Example - Searching for "parks" which are in "California" and are "World Heritage Sites". They must be over 40000 acres or more than 500 square kilometers. The park can not be "Yosemite".
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
  engineName: 'national-parks-demo'
})

const query = 'parks'

const options = { filters: { all: [ { states: 'California' }, { world_heritage_site: 'true' } ], any: [ { acres: { from: 40000 } }, { square_km: { from: 500 } } ], none: [ { title: 'yosemite' } ] } }

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

Arrays as "OR"

When building filters, you can use all three of: any, all, or none.

The following filter shows two arrays nested under the all field.

Given that it is an all field, it creates an "AND" between the two arrays.

Within each array, its items are applied using an "OR" condition.

"filters": {
  "all": [
    { "states": ["Washington", "Idaho"] },
    { "world_heritage_site": ["true"] }
  ]
}

The filter is saying: ( "Washington" OR "Idaho" ) AND "world_heritage_site".

When present as a filtering option, or when nested under any condition, an array is an OR:

"filters": {
  "states": ["Washington", "Idaho"]
}

This filter is saying: Washington OR Idaho.

Arrays vs. Objects

Be mindful of the 32 filters limit when building large filtered queries.

Instead of stacking objects, you can use an array when values share a field.

Each array can contain 1024 values.

If need be, you can use 32 full arrays to filter on a total of 32,768 values.

Array behaviour varies depending on whether you are using any, all, or none...

Arrays: Any

You can stack objects within an any parameter, like so:

"filters" : {
    "any": [
      { "sku": 1 },
      { "sku": 2 },
      { "sku": 3 },
      { "sku": 4 },
      { "sku": 5 },
      { "sku": 6 }
...
...
    ]
  }

Or, you can include them in an array for greater efficiency:

"filters" : {
    "any": [
      "sku": [1, 2, 3, 4, 5, 6 ...]
    ]
  }
Arrays: All, None

If you use an array within an all or none parameter, like so:

"filters" : {
    "all": [
      "sku": [1, 2, 3, 4, 5, 6 ...]
    ]
  }

It is equivalent to nesting an any object under the all or none object:

"filters" : {
    "all": {
      "any": [
        { "sku": 1 },
        { "sku": 2 },
        { "sku": 3 },
        { "sku": 4 },
        { "sku": 5 },
        { "sku": 6 }
      ]
    }
  }

The intention is to chain OR statements.

Nesting Filters

Clauses can be nested within each other to have even more expressive filtering.

Filter can have up to 5 levels of nesting.

Example - Nesting ANY and ALL filters.
curl -X GET 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/national-parks-demo/search' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-soaewu2ye6uc45dr8mcd54v8' \
-d '{
  "query": "parks",
  "filters": {
    "any": [
      {
        "all": [
          { "states": "California" },
          { "world_heritage_site": "true" }
        ]
      }
    ]
  }
}'

Example - Nesting ANY and ALL filters.
import com.swiftype.appsearch.Client;
import com.swiftype.appsearch.ClientException;
import java.util.*;

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

String engineName = "national-parks-demo"; String query = "everglade";

Map<String, String> evergladeStatesFilter = new HashMap<>(); evergladeStatesFilter.put("states", "California"); Map<String, String> evergladeHeritageFilter = new HashMap<>(); evergladeHeritageFilter.put("world_heritage_site", "true"); Map<String, Object> allFilters = new HashMap<>(); allFilters.put("all", Arrays.asList(evergladeStatesFilter, evergladeHeritageFilter));

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

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 - Nesting ANY and ALL filters.
const SwiftypeAppSearchClient = require('swiftype-app-search-node')

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

const engineName = 'national-parks-demo' const query = 'everglade'

const options = { filters: { any: [ { all: [ { states: 'California' }, { world_heritage_site: 'true' } ] } ] } }

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

Example - Nesting ANY and ALL filters.
require 'swiftype-app-search'

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

engine_name = 'national-parks-demo' query = 'everglade'

options = { filters: { any: [ { all: [ { states: 'California' }, { world_heritage_site: 'true' } ] } ] } }

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

Example - Nesting ANY and ALL filters.
from swiftype_app_search import Client
from swiftype_app_search.exceptions import SwiftypeAppSearchError

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

engine_name = 'national-parks-demo' query = 'everglade'

options = { 'filters': { 'any': [ { 'all': [ {'states': 'California'}, {'world_heritage_site': 'true'} ] } ] } }

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

Example - Nesting ANY and ALL filters.
const client = SwiftypeAppSearch.createClient({
  hostIdentifier: 'host-2376rb',
  searchKey: 'search-soaewu2ye6uc45dr8mcd54v8',
  engineName: 'national-parks-demo'
})

const query = 'everglade'

const options = { filters: { any: [ { all: [ { states: 'California' }, { world_heritage_site: 'true' } ] } ] } }

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


Stuck? Looking for help? Contact support or check out the App Search community forum!