Skip to content

Commit 05bd2e3

Browse files
Merge pull request #245100 from HeidiSteen/heidist-gh
moved response configuration to follow query examples
2 parents 15b7829 + ab6aae3 commit 05bd2e3

File tree

2 files changed

+37
-38
lines changed

2 files changed

+37
-38
lines changed

articles/search/vector-search-how-to-create-index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Prior to indexing, assemble a document payload that includes vector data. The do
3737

3838
Vector fields contain vector data generated by embedding models, one embedding per field. We recommend the embedding models in [Azure OpenAI](https://aka.ms/oai/access), such as **text-embedding-ada-002** for text documents or the [Image Retrieval REST API](/rest/api/computervision/2023-02-01-preview/image-retrieval/vectorize-image) for images.
3939

40-
1. Provide other fields with alphanumeric content for the search response and for hybrid query scenarios that include full text search or semantic ranking in the same request.
40+
1. Provide other fields with alphanumeric content for the query response and for hybrid query scenarios that include full text search or semantic ranking in the same request.
4141

4242
Your search index should include fields and content for all of the query scenarios you want to support. Suppose you want to search or filter over product names, versions, metadata, or addresses. In this case, similarity search isn't especially helpful. Keyword search, geo-search, or filters would be a better choice. A search index that includes a comprehensive field collection of vector and non-vector data provides maximum flexibility for query construction and response composition.
4343

articles/search/vector-search-how-to-query.md

Lines changed: 36 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -79,42 +79,6 @@ The expected response is 202 for a successful call to the deployed model. The bo
7979
}
8080
```
8181

82-
## Configure a query response
83-
84-
When you're setting up the vector query, think about the response structure. The response is a flattened rowset. Parameters on the query determine which fields are in each row and how many rows are in the response. The search engine ranks the matching documents and returns the most relevant results.
85-
86-
### Fields in a response
87-
88-
Search results are composed of "retrievable" fields from your search index. A result is either:
89-
90-
+ All "retrievable" fields (a REST API default).
91-
+ Fields explicitly listed in a "select" parameter on the query.
92-
93-
The examples in this article include a "select" statement that specifies text (non-vector) fields to include the response.
94-
95-
> [!NOTE]
96-
> Vectors aren't designed for readability, so avoid returning them in the response. Instead, choose non-vector fields that are representative of the search document. For example, if the query targets a "descriptionVector" field, return an equivalent text field if you have one ("description") in the response.
97-
98-
### Number of results
99-
100-
A query might match to any number of documents, as many as all of them if the search criteria are weak (for example "search=*" for a null query). Because it's seldom practical to return unbounded results, you should specify a maximum for the response:
101-
102-
+ `"k": n` results for vector-only queries
103-
+ `"top": n` results for hybrid queries that include a "search" parameter
104-
105-
Both "k" and "top" are optional. Unspecified, the default number of results in a response is 50. You can set "top" and "skip" to [page through more results](search-pagination-page-layout.md#paging-results) or to change the default.
106-
107-
### Ranking
108-
109-
Ranking of results is computed by either:
110-
111-
+ The similarity metric specified in the index `vectorConfiguration` for a vector-only query. Valid values are `cosine` , `euclidean`, and `dotProduct`.
112-
+ Reciprocal Rank Fusion (RRF) if there are multiple sets of search results.
113-
114-
Azure OpenAI embedding models use cosine similarity, so if you're using Azure OpenAI embedding models, `cosine` is the recommended metric. Other supported ranking metrics include `euclidean` and `dotProduct`.
115-
116-
Multiple sets are created if the query targets multiple vector fields, or if the query is a hybrid of vector and full text search, with or without the optional semantic reranking capabilities of [semantic search](semantic-search-overview.md). Within vector search, a vector query can only target one internal vector index. So for [multiple vector fields](#query-syntax-for-vector-query-over-multiple-fields) and [multiple vector queries](#query-syntax-for-multiple-vector-queries), the search engine generates multiple queries that target the respective vector indexes of each field. Output is a set of ranked results for each query, which are fused using RRF. For more information, see [Vector query execution and scoring](vector-search-ranking.md).
117-
11882
## Query syntax for vector search
11983

12084
In this vector query, which is shortened for brevity, the "value" contains the vectorized text of the query input. The "fields" property specifies which vector fields are searched. The "k" property specifies the number of nearest neighbors to return as top hits.
@@ -245,7 +209,42 @@ You must use REST for this scenario. Currently, there isn't support for multiple
245209

246210
Search results would include a combination of text and images, assuming your search index includes a field for the image file (a search index doesn't store images).
247211

212+
## Configure a query response
213+
214+
When you're setting up the vector query, think about the response structure. The response is a flattened rowset. Parameters on the query determine which fields are in each row and how many rows are in the response. The search engine ranks the matching documents and returns the most relevant results.
215+
216+
### Fields in a response
217+
218+
Search results are composed of "retrievable" fields from your search index. A result is either:
219+
220+
+ All "retrievable" fields (a REST API default).
221+
+ Fields explicitly listed in a "select" parameter on the query.
222+
223+
The examples in this article used a "select" statement to specify text (non-vector) fields in the response.
224+
225+
> [!NOTE]
226+
> Vectors aren't designed for readability, so avoid returning them in the response. Instead, choose non-vector fields that are representative of the search document. For example, if the query targets a "descriptionVector" field, return an equivalent text field if you have one ("description") in the response.
227+
228+
### Number of results
229+
230+
A query might match to any number of documents, as many as all of them if the search criteria are weak (for example "search=*" for a null query). Because it's seldom practical to return unbounded results, you should specify a maximum for the response:
231+
232+
+ `"k": n` results for vector-only queries
233+
+ `"top": n` results for hybrid queries that include a "search" parameter
234+
235+
Both "k" and "top" are optional. Unspecified, the default number of results in a response is 50. You can set "top" and "skip" to [page through more results](search-pagination-page-layout.md#paging-results) or change the default.
236+
237+
### Ranking
238+
239+
Ranking of results is computed by either:
240+
241+
+ The similarity metric specified in the index `vectorConfiguration` for a vector-only query. Valid values are `cosine` , `euclidean`, and `dotProduct`.
242+
+ Reciprocal Rank Fusion (RRF) if there are multiple sets of search results.
243+
244+
Azure OpenAI embedding models use cosine similarity, so if you're using Azure OpenAI embedding models, `cosine` is the recommended metric. Other supported ranking metrics include `euclidean` and `dotProduct`.
245+
246+
Multiple sets are created if the query targets multiple vector fields, or if the query is a hybrid of vector and full text search, with or without the optional semantic reranking capabilities of [semantic search](semantic-search-overview.md). Within vector search, a vector query can only target one internal vector index. So for [multiple vector fields](#query-syntax-for-vector-query-over-multiple-fields) and [multiple vector queries](#query-syntax-for-multiple-vector-queries), the search engine generates multiple queries that target the respective vector indexes of each field. Output is a set of ranked results for each query, which are fused using RRF. For more information, see [Vector query execution and scoring](vector-search-ranking.md).
247+
248248
## Next steps
249249

250250
As a next step, we recommend reviewing the demo code for [Python](https://github.com/Azure/cognitive-search-vector-pr/tree/main/demo-python), or [C#](https://github.com/Azure/cognitive-search-vector-pr/tree/main/demo-dotnet).
251-

0 commit comments

Comments
 (0)