Documents - Suggest Get

Suggests documents in the index that match the given partial query text.

GET {endpoint}/indexes('{indexName}')/docs/search.suggest?search={search}&suggesterName={suggesterName}&api-version=2024-05-01-preview
GET {endpoint}/indexes('{indexName}')/docs/search.suggest?search={search}&suggesterName={suggesterName}&$filter={$filter}&fuzzy={fuzzy}&highlightPostTag={highlightPostTag}&highlightPreTag={highlightPreTag}&minimumCoverage={minimumCoverage}&$orderby={$orderby}&searchFields={searchFields}&$select={$select}&$top={$top}&api-version=2024-05-01-preview

URI Parameters

Name In Required Type Description
endpoint
path True

string

The endpoint URL of the search service.

indexName
path True

string

The name of the index.

api-version
query True

string

Client Api Version.

search
query True

string

The search text to use to suggest documents. Must be at least 1 character, and no more than 100 characters.

suggesterName
query True

string

The name of the suggester as specified in the suggesters collection that's part of the index definition.

$filter
query

string

An OData expression that filters the documents considered for suggestions.

$orderby
query

string[]

The list of OData $orderby expressions by which to sort the results. Each expression can be either a field name or a call to either the geo.distance() or the search.score() functions. Each expression can be followed by asc to indicate ascending, or desc to indicate descending. The default is ascending order. Ties will be broken by the match scores of documents. If no $orderby is specified, the default sort order is descending by document match score. There can be at most 32 $orderby clauses.

$select
query

string[]

The list of fields to retrieve. If unspecified, only the key field will be included in the results.

$top
query

integer

int32

The number of suggestions to retrieve. The value must be a number between 1 and 100. The default is 5.

fuzzy
query

boolean

A value indicating whether to use fuzzy matching for the suggestions query. Default is false. When set to true, the query will find terms even if there's a substituted or missing character in the search text. While this provides a better experience in some scenarios, it comes at a performance cost as fuzzy suggestions queries are slower and consume more resources.

highlightPostTag
query

string

A string tag that is appended to hit highlights. Must be set with highlightPreTag. If omitted, hit highlighting of suggestions is disabled.

highlightPreTag
query

string

A string tag that is prepended to hit highlights. Must be set with highlightPostTag. If omitted, hit highlighting of suggestions is disabled.

minimumCoverage
query

number

double

A number between 0 and 100 indicating the percentage of the index that must be covered by a suggestions query in order for the query to be reported as a success. This parameter can be useful for ensuring search availability even for services with only one replica. The default is 80.

searchFields
query

string[]

The list of field names to search for the specified search text. Target fields must be included in the specified suggester.

Request Header

Name Required Type Description
x-ms-client-request-id

string

uuid

The tracking ID sent with the request to help with debugging.

Responses

Name Type Description
200 OK

SuggestDocumentsResult

Response containing suggested documents that match the partial input.

Other Status Codes

ErrorResponse

Error response.

Examples

SearchIndexSuggestDocumentsGet

Sample request

GET https://myservice.search.windows.net/indexes('myindex')/docs/search.suggest?search=hote&suggesterName=sg&$filter=rating gt 10&fuzzy=False&highlightPostTag=</em>&highlightPreTag=<em>&minimumCoverage=80&$orderby=search.score() desc,rating desc&searchFields=title&$select=docId,title,description&$top=10&api-version=2024-05-01-preview

Sample response

{
  "value": [
    {
      "@search.text": "Nice <em>Hotel</em>",
      "description": "Cheapest hotel in town",
      "docId": "1",
      "title": "Nice Hotel"
    },
    {
      "@search.text": "Fancy <em>Hotel</em>",
      "description": "Best hotel in town",
      "docId": "2",
      "title": "Fancy Hotel"
    }
  ]
}

Definitions

Name Description
ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

SuggestDocumentsResult

Response containing suggestion query results from an index.

SuggestResult

A result containing a document found by a suggestion query, plus associated metadata.

ErrorAdditionalInfo

The resource management error additional info.

Name Type Description
info

object

The additional info.

type

string

The additional info type.

ErrorDetail

The error detail.

Name Type Description
additionalInfo

ErrorAdditionalInfo[]

The error additional info.

code

string

The error code.

details

ErrorDetail[]

The error details.

message

string

The error message.

target

string

The error target.

ErrorResponse

Error response

Name Type Description
error

ErrorDetail

The error object.

SuggestDocumentsResult

Response containing suggestion query results from an index.

Name Type Description
@search.coverage

number

A value indicating the percentage of the index that was included in the query, or null if minimumCoverage was not set in the request.

value

SuggestResult[]

The sequence of results returned by the query.

SuggestResult

A result containing a document found by a suggestion query, plus associated metadata.

Name Type Description
@search.text

string

The text of the suggestion result.