Documents - Search Post

Searches for documents in the index.

POST {endpoint}/indexes('{indexName}')/docs/search.post.search?api-version=2023-11-01

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.

Request Header

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

string

uuid

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

Request Body

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.

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[]:

RawVectorQuery[]

The query parameters for vector and hybrid search queries.

Responses

Name Type Description
200 OK

SearchDocumentsResult

Response containing documents that match the search criteria.

Other Status Codes

SearchError

Error response.

Examples

SearchIndexSearchDocumentsPost
SearchIndexSearchDocumentsSemanticPost

SearchIndexSearchDocumentsPost

Sample Request

POST https://myservice.search.windows.net/indexes('myindex')/docs/search.post.search?api-version=2023-11-01

{
  "count": true,
  "facets": [
    "category,count:10,sort:count"
  ],
  "filter": "rating gt 4.0",
  "highlight": "description",
  "highlightPostTag": "</em>",
  "highlightPreTag": "<em>",
  "minimumCoverage": null,
  "orderby": "rating desc",
  "queryType": "simple",
  "scoringParameters": [
    "currentLocation--122.123,44.77233"
  ],
  "scoringProfile": "sp",
  "search": "nice hotels",
  "searchFields": "category,description",
  "searchMode": "any",
  "sessionId": "mysessionid",
  "scoringStatistics": "global",
  "select": "hotelId,category,description",
  "skip": 0,
  "top": 10,
  "vectorQueries": [
    {
      "kind": "vector",
      "vector": [
        0.103,
        0.0712,
        0.0852,
        0.1547,
        0.1183
      ],
      "fields": "descriptionEmbedding",
      "k": 5,
      "exhaustive": true
    }
  ],
  "vectorFilterMode": "preFilter"
}

Sample Response

{
  "@odata.count": 25,
  "@search.facets": {
    "category": [
      {
        "count": 1,
        "value": "Economy"
      },
      {
        "count": 1,
        "value": "Luxury"
      }
    ]
  },
  "@search.nextPageParameters": {
    "count": true,
    "facets": [
      "category,count:10,sort:count"
    ],
    "filter": "rating gt 4.0",
    "highlight": "title",
    "highlightPostTag": "</em>",
    "highlightPreTag": "<em>",
    "minimumCoverage": null,
    "orderby": "search.score() desc,rating desc",
    "queryType": "simple",
    "sessionId": "mysessionid",
    "scoringStatistics": "global",
    "scoringParameters": [
      "currentLocation--122.123,44.77233"
    ],
    "scoringProfile": "sp",
    "search": "nice hotels",
    "searchFields": "title,description",
    "searchMode": "any",
    "select": "docId,title,description",
    "skip": 2,
    "top": 8
  },
  "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"
    }
  ],
  "@odata.nextLink": "https://myservice.search.windows.net/indexes('myindex')/docs/search.post.search?api-version=2023-11-01"
}

SearchIndexSearchDocumentsSemanticPost

Sample Request

POST https://myservice.search.windows.net/indexes('myindex')/docs/search.post.search?api-version=2023-11-01

{
  "count": true,
  "highlightPostTag": "</em>",
  "highlightPreTag": "<em>",
  "queryType": "semantic",
  "search": "how do clouds form",
  "semanticConfiguration": "my-semantic-config",
  "answers": "extractive|count-3",
  "captions": "extractive|highlight-true",
  "semanticErrorHandling": "partial",
  "semanticMaxWaitInMilliseconds": 780
}

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
    }
  ],
  "@search.nextPageParameters": {
    "count": true,
    "highlightPostTag": "</em>",
    "highlightPreTag": "<em>",
    "queryType": "semantic",
    "search": "how do clouds form",
    "semanticConfiguration": "my-semantic-config",
    "answers": "extractive|count-3",
    "captions": "extractive|highlight-true",
    "semanticErrorHandling": "partial",
    "semanticMaxWaitInMilliseconds": 780,
    "skip": 2,
    "top": 8
  },
  "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"
      ]
    }
  ],
  "@odata.nextLink": "https://myservice.search.windows.net/indexes('myindex')/docs/search.post.search?api-version=2023-11-01"
}

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.

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.

SearchError

Describes an error condition for the API.

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.

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.

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.

vector

number[]

The vector representation of a search 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. 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.

SearchError

Describes an error condition for the API.

Name Type Description
code

string

One of a server-defined set of error codes.

details

SearchError[]

An array of details about specific errors that led to this reported error.

message

string

A human-readable representation of the error.

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.

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[]:

RawVectorQuery[]

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.

VectorQueryKind

The kind of vector query being performed.

Name Type Description
vector

string

Vector query where a raw vector value is provided.