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 Fields (Weights)

Learn more about Weights within the Relevance Tuning guide.


The search_fields parameter restricts a query to search only specific fields.

Restricting fields will result in faster queries, especially for schemas with many text fields.

Only available within text fields.

query
required
A string or number used to find related documents. See here for more details.
search_fields
required
Send in a search_fields object with your query.
fields
optional
Fields must exist within your Engine schema and be of type text.
weight
optional
Weight is given between 10 (most relevant) to 1 (least relevant).
Example - Specifying search_fields for a given query.
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 '{
  "search_fields": {
    "title": {},
    "description": {},
    "states": {}
  },
  "query": "everglade"
}'

Example - Specifying search_fields for a given query.
No Java example available, showing cURL
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 '{
  "search_fields": {
    "title": {},
    "description": {},
    "states": {}
  },
  "query": "everglade"
}'

Example - Specifying search_fields for a given query.
No Node example available, showing cURL
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 '{
  "search_fields": {
    "title": {},
    "description": {},
    "states": {}
  },
  "query": "everglade"
}'

Example - Specifying search_fields for a given query.
No Ruby example available, showing cURL
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 '{
  "search_fields": {
    "title": {},
    "description": {},
    "states": {}
  },
  "query": "everglade"
}'

Example - Specifying search_fields for a given query.
No Python example available, showing cURL
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 '{
  "search_fields": {
    "title": {},
    "description": {},
    "states": {}
  },
  "query": "everglade"
}'

Example - Specifying search_fields for a given query.
No Javascript example available, showing cURL
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 '{
  "search_fields": {
    "title": {},
    "description": {},
    "states": {}
  },
  "query": "everglade"
}'

Search Fields with Weight

Apply Weights to each search field.

Engine level Weight settings will be applied is none are provided.

Query time Weights take precedence over Engine level values.

Example - Specifying weights to favor the park title, followed by its description, and then their states.
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 '{
  "search_fields": {
    "title": {
      "weight": 10
    },
    "description": {
      "weight": 5
    },
    "states": {
      "weight": 3
    }
  },
  "query": "everglade"
}'

Example - Specifying weights to favor the park title, followed by its description, and then their states.
No Java example available, showing cURL
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 '{
  "search_fields": {
    "title": {
      "weight": 10
    },
    "description": {
      "weight": 5
    },
    "states": {
      "weight": 3
    }
  },
  "query": "everglade"
}'

Example - Specifying weights to favor the park title, followed by its description, and then their states.
No Node example available, showing cURL
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 '{
  "search_fields": {
    "title": {
      "weight": 10
    },
    "description": {
      "weight": 5
    },
    "states": {
      "weight": 3
    }
  },
  "query": "everglade"
}'

Example - Specifying weights to favor the park title, followed by its description, and then their states.
No Ruby example available, showing cURL
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 '{
  "search_fields": {
    "title": {
      "weight": 10
    },
    "description": {
      "weight": 5
    },
    "states": {
      "weight": 3
    }
  },
  "query": "everglade"
}'

Example - Specifying weights to favor the park title, followed by its description, and then their states.
No Python example available, showing cURL
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 '{
  "search_fields": {
    "title": {
      "weight": 10
    },
    "description": {
      "weight": 5
    },
    "states": {
      "weight": 3
    }
  },
  "query": "everglade"
}'

Example - Specifying weights to favor the park title, followed by its description, and then their states.
No Javascript example available, showing cURL
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 '{
  "search_fields": {
    "title": {
      "weight": 10
    },
    "description": {
      "weight": 5
    },
    "states": {
      "weight": 3
    }
  },
  "query": "everglade"
}'

Errors

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.

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