Documents - Search Get

Searches for documents in the index.

GET {endpoint}/indexes('{indexName}')/docs?api-version=2024-07-01
GET {endpoint}/indexes('{indexName}')/docs?search={search}&$count={$count}&facet={facet}&$filter={$filter}&highlight={highlight}&highlightPostTag={highlightPostTag}&highlightPreTag={highlightPreTag}&minimumCoverage={minimumCoverage}&$orderby={$orderby}&queryType={queryType}&scoringParameter={scoringParameter}&scoringProfile={scoringProfile}&searchFields={searchFields}&searchMode={searchMode}&scoringStatistics={scoringStatistics}&sessionId={sessionId}&$select={$select}&$skip={$skip}&$top={$top}&api-version=2024-07-01&semanticConfiguration={semanticConfiguration}&semanticErrorHandling={semanticErrorHandling}&semanticMaxWaitInMilliseconds={semanticMaxWaitInMilliseconds}&answers={answers}&captions={captions}&semanticQuery={semanticQuery}

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.

$count
query

boolean

A value that specifies whether to fetch the total count of results. Default is false. Setting this value to true may have a performance impact. Note that the count returned is an approximation.

$filter
query

string

The OData $filter expression to apply to the search query.

$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, and 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, all fields marked as retrievable in the schema are included.

$skip
query

integer

int32

The number of search results to skip. This value cannot be greater than 100,000. If you need to scan documents in sequence, but cannot use $skip due to this limitation, consider using $orderby on a totally-ordered key and $filter with a range query instead.

$top
query

integer

int32

The number of search results to retrieve. This can be used in conjunction with $skip to implement client-side paging of search results. If results are truncated due to server-side paging, the response will include a continuation token that can be used to issue another Search request for the next page of results.

answers
query

QueryAnswerType

This parameter is only valid if the query type is semantic. If set, the query returns answers extracted from key passages in the highest ranked documents. The number of answers returned can be configured by appending the pipe character | followed by the count-<number of answers> option after the answers parameter value, such as extractive|count-3. Default count is 1. The confidence threshold can be configured by appending the pipe character | followed by the threshold-<confidence threshold> option after the answers parameter value, such as extractive|threshold-0.9. Default threshold is 0.7.

captions
query

QueryCaptionType

This parameter is only valid if the query type is semantic. If set, the query returns captions extracted from key passages in the highest ranked documents. When Captions is set to extractive, highlighting is enabled by default, and can be configured by appending the pipe character | followed by the highlight-<true/false> option, such as extractive|highlight-true. Defaults to None.

facet
query

string[]

The list of facet expressions to apply to the search query. Each facet expression contains a field name, optionally followed by a comma-separated list of name:value pairs.

highlight
query

string[]

The list of field names to use for hit highlights. Only searchable fields can be used for hit highlighting.

highlightPostTag
query

string

A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is </em>.

highlightPreTag
query

string

A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default is <em>.

minimumCoverage
query

number

double

A number between 0 and 100 indicating the percentage of the index that must be covered by a search 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 100.

queryType
query

QueryType

A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax.

scoringParameter
query

string[]

The list of parameter values to be used in scoring functions (for example, referencePointParameter) using the format name-values. For example, if the scoring profile defines a function with a parameter called 'mylocation' the parameter string would be "mylocation--122.2,44.8" (without the quotes).

scoringProfile
query

string

The name of a scoring profile to evaluate match scores for matching documents in order to sort the results.

scoringStatistics
query

ScoringStatistics

A value that specifies whether we want to calculate scoring statistics (such as document frequency) globally for more consistent scoring, or locally, for lower latency.

search
query

string

A full-text search query expression; Use "*" or omit this parameter to match all documents.

searchFields
query

string[]

The list of field names to which to scope the full-text search. When using fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each fielded search expression take precedence over any field names listed in this parameter.

searchMode
query

SearchMode

A value that specifies whether any or all of the search terms must be matched in order to count the document as a match.

semanticConfiguration
query

string

The name of the semantic configuration that lists which fields should be used for semantic ranking, captions, highlights, and answers

semanticErrorHandling
query

SemanticErrorMode

Allows the user to choose whether a semantic call should fail completely, or to return partial results (default).

semanticMaxWaitInMilliseconds
query

integer

int32

Allows the user to set an upper bound on the amount of time it takes for semantic enrichment to finish processing before the request fails.

semanticQuery
query

string

Allows setting a separate search query that will be solely used for semantic reranking, semantic captions and semantic answers. Is useful for scenarios where there is a need to use different queries between the base retrieval and ranking phase, and the L2 semantic phase.

sessionId
query

string

A value to be used to create a sticky session, which can help to get more consistent results. As long as the same sessionId is used, a best-effort attempt will be made to target the same replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the load balancing of the requests across replicas and adversely affect the performance of the search service. The value used as sessionId cannot start with a '_' character.

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

SearchDocumentsResult

Response containing documents that match the search criteria.

Other Status Codes

ErrorResponse

Error response.

Examples

SearchIndexSearchDocumentsGet
SearchIndexSearchDocumentsSemanticGet

SearchIndexSearchDocumentsGet

Sample request

GET https://myservice.search.windows.net/indexes('myindex')/docs?search=nice hotels&$count=True&facet=category,count:10,sort:count&$filter=rating gt 10&highlight=title&highlightPostTag=</em>&highlightPreTag=<em>&minimumCoverage=80&$orderby=search.score() desc,rating desc&queryType=simple&scoringProfile=sp&searchFields=title,description&searchMode=any&scoringStatistics=global&sessionId=mysessionid&$select=docId,title,description&$skip=100&$top=10&api-version=2024-07-01

Sample response

{
  "@odata.count": 25,
  "@search.coverage": 80,
  "@search.facets": {
    "category": [
      {
        "count": 1,
        "value": "Economy"
      },
      {
        "count": 1,
        "value": "Luxury"
      }
    ]
  },
  "value": [
    {
      "@search.score": 1.5,
      "@search.highlights": {
        "title": [
          "<em>Nice</em> <em>Hotel</em>"
        ]
      },
      "description": "Cheapest hotel in town",
      "docId": "1",
      "title": "Nice Hotel"
    },
    {
      "@search.score": 0.7,
      "@search.highlights": {
        "title": [
          "Fancy <em>Hotel</em>"
        ]
      },
      "description": "Best hotel in town",
      "docId": "2",
      "title": "Fancy Hotel"
    }
  ]
}

SearchIndexSearchDocumentsSemanticGet

Sample request

GET https://myservice.search.windows.net/indexes('myindex')/docs?search=how do clouds form&$count=True&highlightPostTag=</em>&highlightPreTag=<em>&queryType=semantic&api-version=2024-07-01&semanticConfiguration=my-semantic-config&semanticErrorHandling=partial&semanticMaxWaitInMilliseconds=780&answers=extractive|count-3&captions=extractive|highlight-true&semanticQuery={semanticQuery}

Sample response

{
  "@odata.count": 25,
  "@search.answers": [
    {
      "key": "4123",
      "text": "Sunlight heats the land all day, warming that moist air and causing it to rise high into the   atmosphere until it cools and condenses into water droplets. Clouds generally form where air is ascending (over land in this case),   but not where it is descending (over the river).",
      "highlights": "Sunlight heats the land all day, warming that moist air and causing it to rise high into the   atmosphere until it cools and condenses into water droplets. Clouds generally form<em> where air is ascending</em> (over land in this case),   but not where it is<em> descending</em> (over the river).",
      "score": 0.94639826
    }
  ],
  "value": [
    {
      "@search.score": 0.5479723,
      "@search.rerankerScore": 1.0321671911515296,
      "@search.captions": [
        {
          "text": "Like all clouds, it forms when the air reaches its dew point—the temperature at which an air mass is cool enough for its water vapor to condense into liquid droplets. This false-color image shows valley fog, which is common in the Pacific Northwest of North America.",
          "highlights": "Like all<em> clouds</em>, it<em> forms</em> when the air reaches its dew point—the temperature at    which an air mass is cool enough for its water vapor to condense into liquid droplets. This false-color image shows valley<em> fog</em>, which is common in the Pacific Northwest of North America."
        }
      ],
      "id": "4123",
      "title": "Earth Atmosphere",
      "content": "Fog is essentially a cloud lying on the ground. Like all clouds, it forms when the air reaches its dew point—the temperature at  \n\nwhich an air mass is cool enough for its water vapor to condense into liquid droplets.\n\nThis false-color image shows valley fog, which is common in the Pacific Northwest of North America. On clear winter nights, the \n\nground and overlying air cool off rapidly, especially at high elevations. Cold air is denser than warm air, and it sinks down into the \n\nvalleys. The moist air in the valleys gets chilled to its dew point, and fog forms. If undisturbed by winds, such fog may persist for \n\ndays. The Terra satellite captured this image of foggy valleys northeast of Vancouver in February 2010.\n\n\n",
      "locations": [
        "Pacific Northwest",
        "North America",
        "Vancouver"
      ]
    }
  ]
}

Definitions

Name Description
AnswerResult

An answer is a text passage extracted from the contents of the most relevant documents that matched the query. Answers are extracted from the top search results. Answer candidates are scored and the top answers are selected.

CaptionResult

Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type semantic.

ErrorAdditionalInfo

The resource management error additional info.

ErrorDetail

The error detail.

ErrorResponse

Error response

QueryAnswerType

A value that specifies whether answers should be returned as part of the search response.

QueryCaptionType

A value that specifies whether captions should be returned as part of the search response.

QueryType

Specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax.

RawVectorQuery

The query parameters to use for vector search when a raw vector value is provided.

ScoringStatistics

A value that specifies whether we want to calculate scoring statistics (such as document frequency) globally for more consistent scoring, or locally, for lower latency. The default is 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global scoring statistics can increase latency of search queries.

SearchDocumentsResult

Response containing search results from an index.

SearchMode

Specifies whether any or all of the search terms must be matched in order to count the document as a match.

SearchRequest

Parameters for filtering, sorting, faceting, paging, and other search query behaviors.

SearchResult

Contains a document found by a search query, plus associated metadata.

SemanticErrorMode

Allows the user to choose whether a semantic call should fail completely (default / current behavior), or to return partial results.

SemanticErrorReason

Reason that a partial response was returned for a semantic ranking request.

SemanticSearchResultsType

Type of partial response that was returned for a semantic ranking request.

VectorFilterMode

Determines whether or not filters are applied before or after the vector search is performed.

VectorizableTextQuery

The query parameters to use for vector search when a text value that needs to be vectorized is provided.

VectorQueryKind

The kind of vector query being performed.

AnswerResult

An answer is a text passage extracted from the contents of the most relevant documents that matched the query. Answers are extracted from the top search results. Answer candidates are scored and the top answers are selected.

Name Type Description
highlights

string

Same text passage as in the Text property with highlighted text phrases most relevant to the query.

key

string

The key of the document the answer was extracted from.

score

number

The score value represents how relevant the answer is to the query relative to other answers returned for the query.

text

string

The text passage extracted from the document contents as the answer.

CaptionResult

Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type semantic.

Name Type Description
highlights

string

Same text passage as in the Text property with highlighted phrases most relevant to the query.

text

string

A representative text passage extracted from the document most relevant to the search query.

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.

QueryAnswerType

A value that specifies whether answers should be returned as part of the search response.

Name Type Description
extractive

string

Extracts answer candidates from the contents of the documents returned in response to a query expressed as a question in natural language.

none

string

Do not return answers for the query.

QueryCaptionType

A value that specifies whether captions should be returned as part of the search response.

Name Type Description
extractive

string

Extracts captions from the matching documents that contain passages relevant to the search query.

none

string

Do not return captions for the query.

QueryType

Specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax.

Name Type Description
full

string

Uses the full Lucene query syntax for searches. Search text is interpreted using the Lucene query language which allows field-specific and weighted searches, as well as other advanced features.

semantic

string

Best suited for queries expressed in natural language as opposed to keywords. Improves precision of search results by re-ranking the top search results using a ranking model trained on the Web corpus.

simple

string

Uses the simple query syntax for searches. Search text is interpreted using a simple query language that allows for symbols such as +, * and "". Queries are evaluated across all searchable fields by default, unless the searchFields parameter is specified.

RawVectorQuery

The query parameters to use for vector search when a raw vector value is provided.

Name Type Description
exhaustive

boolean

When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index. Useful for scenarios where exact matches are critical, such as determining ground truth values.

fields

string

Vector Fields of type Collection(Edm.Single) to be included in the vector searched.

k

integer

Number of nearest neighbors to return as top hits.

kind string:

vector

The kind of vector query being performed.

oversampling

number

Oversampling factor. Minimum value is 1. It overrides the 'defaultOversampling' parameter configured in the index definition. It can be set only when 'rerankWithOriginalVectors' is true. This parameter is only permitted when a compression method is used on the underlying vector field.

vector

number[]

The vector representation of a search query.

weight

number

Relative weight of the vector query when compared to other vector query and/or the text query within the same search request. This value is used when combining the results of multiple ranking lists produced by the different vector queries and/or the results retrieved through the text query. The higher the weight, the higher the documents that matched that query will be in the final ranking. Default is 1.0 and the value needs to be a positive number larger than zero.

ScoringStatistics

A value that specifies whether we want to calculate scoring statistics (such as document frequency) globally for more consistent scoring, or locally, for lower latency. The default is 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global scoring statistics can increase latency of search queries.

Name Type Description
global

string

The scoring statistics will be calculated globally for more consistent scoring.

local

string

The scoring statistics will be calculated locally for lower latency.

SearchDocumentsResult

Response containing search results from an index.

Name Type Description
@odata.count

integer

The total count of results found by the search operation, or null if the count was not requested. If present, the count may be greater than the number of results in this response. This can happen if you use the $top or $skip parameters, or if the query can't return all the requested documents in a single response.

@odata.nextLink

string

Continuation URL returned when the query can't return all the requested results in a single response. You can use this URL to formulate another GET or POST Search request to get the next part of the search response. Make sure to use the same verb (GET or POST) as the request that produced this response.

@search.answers

AnswerResult[]

The answers query results for the search operation; null if the answers query parameter was not specified or set to 'none'.

@search.coverage

number

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

@search.facets

object

The facet query results for the search operation, organized as a collection of buckets for each faceted field; null if the query did not include any facet expressions.

@search.nextPageParameters

SearchRequest

Continuation JSON payload returned when the query can't return all the requested results in a single response. You can use this JSON along with @odata.nextLink to formulate another POST Search request to get the next part of the search response.

@search.semanticPartialResponseReason

SemanticErrorReason

Reason that a partial response was returned for a semantic ranking request.

@search.semanticPartialResponseType

SemanticSearchResultsType

Type of partial response that was returned for a semantic ranking request.

value

SearchResult[]

The sequence of results returned by the query.

SearchMode

Specifies whether any or all of the search terms must be matched in order to count the document as a match.

Name Type Description
all

string

All of the search terms must be matched in order to count the document as a match.

any

string

Any of the search terms must be matched in order to count the document as a match.

SearchRequest

Parameters for filtering, sorting, faceting, paging, and other search query behaviors.

Name Type Description
answers

QueryAnswerType

A value that specifies whether answers should be returned as part of the search response.

captions

QueryCaptionType

A value that specifies whether captions should be returned as part of the search response.

count

boolean

A value that specifies whether to fetch the total count of results. Default is false. Setting this value to true may have a performance impact. Note that the count returned is an approximation.

facets

string[]

The list of facet expressions to apply to the search query. Each facet expression contains a field name, optionally followed by a comma-separated list of name:value pairs.

filter

string

The OData $filter expression to apply to the search query.

highlight

string

The comma-separated list of field names to use for hit highlights. Only searchable fields can be used for hit highlighting.

highlightPostTag

string

A string tag that is appended to hit highlights. Must be set with highlightPreTag. Default is </em>.

highlightPreTag

string

A string tag that is prepended to hit highlights. Must be set with highlightPostTag. Default is <em>.

minimumCoverage

number

A number between 0 and 100 indicating the percentage of the index that must be covered by a search 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 100.

orderby

string

The comma-separated 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.

queryType

QueryType

A value that specifies the syntax of the search query. The default is 'simple'. Use 'full' if your query uses the Lucene query syntax.

scoringParameters

string[]

The list of parameter values to be used in scoring functions (for example, referencePointParameter) using the format name-values. For example, if the scoring profile defines a function with a parameter called 'mylocation' the parameter string would be "mylocation--122.2,44.8" (without the quotes).

scoringProfile

string

The name of a scoring profile to evaluate match scores for matching documents in order to sort the results.

scoringStatistics

ScoringStatistics

A value that specifies whether we want to calculate scoring statistics (such as document frequency) globally for more consistent scoring, or locally, for lower latency. The default is 'local'. Use 'global' to aggregate scoring statistics globally before scoring. Using global scoring statistics can increase latency of search queries.

search

string

A full-text search query expression; Use "*" or omit this parameter to match all documents.

searchFields

string

The comma-separated list of field names to which to scope the full-text search. When using fielded search (fieldName:searchExpression) in a full Lucene query, the field names of each fielded search expression take precedence over any field names listed in this parameter.

searchMode

SearchMode

A value that specifies whether any or all of the search terms must be matched in order to count the document as a match.

select

string

The comma-separated list of fields to retrieve. If unspecified, all fields marked as retrievable in the schema are included.

semanticConfiguration

string

The name of a semantic configuration that will be used when processing documents for queries of type semantic.

semanticErrorHandling

SemanticErrorMode

Allows the user to choose whether a semantic call should fail completely (default / current behavior), or to return partial results.

semanticMaxWaitInMilliseconds

integer

Allows the user to set an upper bound on the amount of time it takes for semantic enrichment to finish processing before the request fails.

semanticQuery

string

Allows setting a separate search query that will be solely used for semantic reranking, semantic captions and semantic answers. Is useful for scenarios where there is a need to use different queries between the base retrieval and ranking phase, and the L2 semantic phase.

sessionId

string

A value to be used to create a sticky session, which can help getting more consistent results. As long as the same sessionId is used, a best-effort attempt will be made to target the same replica set. Be wary that reusing the same sessionID values repeatedly can interfere with the load balancing of the requests across replicas and adversely affect the performance of the search service. The value used as sessionId cannot start with a '_' character.

skip

integer

The number of search results to skip. This value cannot be greater than 100,000. If you need to scan documents in sequence, but cannot use skip due to this limitation, consider using orderby on a totally-ordered key and filter with a range query instead.

top

integer

The number of search results to retrieve. This can be used in conjunction with $skip to implement client-side paging of search results. If results are truncated due to server-side paging, the response will include a continuation token that can be used to issue another Search request for the next page of results.

vectorFilterMode

VectorFilterMode

Determines whether or not filters are applied before or after the vector search is performed. Default is 'preFilter' for new indexes.

vectorQueries VectorQuery[]:

The query parameters for vector and hybrid search queries.

SearchResult

Contains a document found by a search query, plus associated metadata.

Name Type Description
@search.captions

CaptionResult[]

Captions are the most representative passages from the document relatively to the search query. They are often used as document summary. Captions are only returned for queries of type 'semantic'.

@search.highlights

object

Text fragments from the document that indicate the matching search terms, organized by each applicable field; null if hit highlighting was not enabled for the query.

@search.rerankerScore

number

The relevance score computed by the semantic ranker for the top search results. Search results are sorted by the RerankerScore first and then by the Score. RerankerScore is only returned for queries of type 'semantic'.

@search.score

number

The relevance score of the document compared to other documents returned by the query.

SemanticErrorMode

Allows the user to choose whether a semantic call should fail completely (default / current behavior), or to return partial results.

Name Type Description
fail

string

If there is an exception during the semantic processing step, the query will fail and return the appropriate HTTP code depending on the error.

partial

string

If the semantic processing fails, partial results still return. The definition of partial results depends on what semantic step failed and what was the reason for failure.

SemanticErrorReason

Reason that a partial response was returned for a semantic ranking request.

Name Type Description
capacityOverloaded

string

The request was throttled. Only the base results were returned.

maxWaitExceeded

string

If semanticMaxWaitInMilliseconds was set and the semantic processing duration exceeded that value. Only the base results were returned.

transient

string

At least one step of the semantic process failed.

SemanticSearchResultsType

Type of partial response that was returned for a semantic ranking request.

Name Type Description
baseResults

string

Results without any semantic enrichment or reranking.

rerankedResults

string

Results have been reranked with the reranker model and will include semantic captions. They will not include any answers, answers highlights or caption highlights.

VectorFilterMode

Determines whether or not filters are applied before or after the vector search is performed.

Name Type Description
postFilter

string

The filter will be applied after the candidate set of vector results is returned. Depending on the filter selectivity, this can result in fewer results than requested by the parameter 'k'.

preFilter

string

The filter will be applied before the search query.

VectorizableTextQuery

The query parameters to use for vector search when a text value that needs to be vectorized is provided.

Name Type Description
exhaustive

boolean

When true, triggers an exhaustive k-nearest neighbor search across all vectors within the vector index. Useful for scenarios where exact matches are critical, such as determining ground truth values.

fields

string

Vector Fields of type Collection(Edm.Single) to be included in the vector searched.

k

integer

Number of nearest neighbors to return as top hits.

kind string:

text

The kind of vector query being performed.

oversampling

number

Oversampling factor. Minimum value is 1. It overrides the 'defaultOversampling' parameter configured in the index definition. It can be set only when 'rerankWithOriginalVectors' is true. This parameter is only permitted when a compression method is used on the underlying vector field.

text

string

The text to be vectorized to perform a vector search query.

weight

number

Relative weight of the vector query when compared to other vector query and/or the text query within the same search request. This value is used when combining the results of multiple ranking lists produced by the different vector queries and/or the results retrieved through the text query. The higher the weight, the higher the documents that matched that query will be in the final ranking. Default is 1.0 and the value needs to be a positive number larger than zero.

VectorQueryKind

The kind of vector query being performed.

Name Type Description
text

string

Vector query where a text value that needs to be vectorized is provided.

vector

string

Vector query where a raw vector value is provided.