Query Suggestion
Want to learn more? Explore the Query Suggestions guide.
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 thetypes
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 10.
GET
/api/as/v1/engines/{ENGINE_NAME}/query_suggestion
POST
/api/as/v1/engines/{ENGINE_NAME}/query_suggestion
Example - A
GET
request to national-parks-demo
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/national-parks-demo/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 national-parks-demo
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/national-parks-demo/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 national-parks-demo
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/national-parks-demo/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 national-parks-demo
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/national-parks-demo/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 national-parks-demo
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/national-parks-demo/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 national-parks-demo
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/national-parks-demo/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!