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

Query Suggestion

Provide relevant query suggestions for incomplete queries.

Also known as Autocomplete

Requires a Public Search Key.

Only available on text fields.

query
required
A partial query for which to receive suggestions.
types
optional
Specify the documents key within the types parameter to look for suggestions within certain text fields. Defaults to all text fields.
size
optional
Number of query suggestions to return. Must be between 1 and 20. Defaults to 5.
GET /api/as/v1/engines/:engine_slug/query_suggestion
POST /api/as/v1/engines/:engine_slug/query_suggestion
Example - A GET request to sample-engine to receive suggestions for the "car" query from the title and state text fields.
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/sample-engine/query_suggestion' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-7eud55t7ecdmqzcanjsc9cqu' \
-d '{
  "query": "car",
  "types": {
    "documents": {
      "fields": [
        "title",
        "states"
      ]
    }
  },
  "size": 4
}'
Example Response
{
  "results": {
    "documents": [
      {
        "suggestion": "carlsbad"
      },
      {
        "suggestion": "carlsbad caverns"
      },
      {
        "suggestion": "carolina"
      }
    ]
  },
  "meta": {
    "request_id": "914f909793379ed5af9379b4401f19be"
  }
}

Example - A GET request to sample-engine to receive suggestions for the "car" query from the title and state text fields.
No Java example available, showing cURL
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/sample-engine/query_suggestion' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-7eud55t7ecdmqzcanjsc9cqu' \
-d '{
  "query": "car",
  "types": {
    "documents": {
      "fields": [
        "title",
        "states"
      ]
    }
  },
  "size": 4
}'
Example Response
No Java example available, showing cURL
{
  "results": {
    "documents": [
      {
        "suggestion": "carlsbad"
      },
      {
        "suggestion": "carlsbad caverns"
      },
      {
        "suggestion": "carolina"
      }
    ]
  },
  "meta": {
    "request_id": "914f909793379ed5af9379b4401f19be"
  }
}

Example - A GET request to sample-engine to receive suggestions for the "car" query from the title and state text fields.
No Node example available, showing cURL
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/sample-engine/query_suggestion' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-7eud55t7ecdmqzcanjsc9cqu' \
-d '{
  "query": "car",
  "types": {
    "documents": {
      "fields": [
        "title",
        "states"
      ]
    }
  },
  "size": 4
}'
Example Response
No Node example available, showing cURL
{
  "results": {
    "documents": [
      {
        "suggestion": "carlsbad"
      },
      {
        "suggestion": "carlsbad caverns"
      },
      {
        "suggestion": "carolina"
      }
    ]
  },
  "meta": {
    "request_id": "914f909793379ed5af9379b4401f19be"
  }
}

Example - A GET request to sample-engine to receive suggestions for the "car" query from the title and state text fields.
No Ruby example available, showing cURL
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/sample-engine/query_suggestion' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-7eud55t7ecdmqzcanjsc9cqu' \
-d '{
  "query": "car",
  "types": {
    "documents": {
      "fields": [
        "title",
        "states"
      ]
    }
  },
  "size": 4
}'
Example Response
No Ruby example available, showing cURL
{
  "results": {
    "documents": [
      {
        "suggestion": "carlsbad"
      },
      {
        "suggestion": "carlsbad caverns"
      },
      {
        "suggestion": "carolina"
      }
    ]
  },
  "meta": {
    "request_id": "914f909793379ed5af9379b4401f19be"
  }
}

Example - A GET request to sample-engine to receive suggestions for the "car" query from the title and state text fields.
No Python example available, showing cURL
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/sample-engine/query_suggestion' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-7eud55t7ecdmqzcanjsc9cqu' \
-d '{
  "query": "car",
  "types": {
    "documents": {
      "fields": [
        "title",
        "states"
      ]
    }
  },
  "size": 4
}'
Example Response
No Python example available, showing cURL
{
  "results": {
    "documents": [
      {
        "suggestion": "carlsbad"
      },
      {
        "suggestion": "carlsbad caverns"
      },
      {
        "suggestion": "carolina"
      }
    ]
  },
  "meta": {
    "request_id": "914f909793379ed5af9379b4401f19be"
  }
}

Example - A GET request to sample-engine to receive suggestions for the "car" query from the title and state text fields.
No Javascript example available, showing cURL
curl -X POST 'https://host-2376rb.api.swiftype.com/api/as/v1/engines/sample-engine/query_suggestion' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer search-7eud55t7ecdmqzcanjsc9cqu' \
-d '{
  "query": "car",
  "types": {
    "documents": {
      "fields": [
        "title",
        "states"
      ]
    }
  },
  "size": 4
}'
Example Response
No Javascript example available, showing cURL
{
  "results": {
    "documents": [
      {
        "suggestion": "carlsbad"
      },
      {
        "suggestion": "carlsbad caverns"
      },
      {
        "suggestion": "carolina"
      }
    ]
  },
  "meta": {
    "request_id": "914f909793379ed5af9379b4401f19be"
  }
}


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