Skip to content

Commit 1a4b0dc

Browse files
authored
Merge pull request #115229 from LuisCabrer/patch-92
Added session id concept
2 parents fa2820e + 919030c commit 1a4b0dc

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

articles/search/index-similarity-and-scoring.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can customize the way different fields are ranked by defining a custom *scor
3131

3232
A scoring profile is part of the index definition, composed of weighted fields, functions, and parameters. For more information about defining one, see [Scoring Profiles](index-add-scoring-profiles.md).
3333

34-
## Scoring statistics
34+
## Scoring statistics and sticky sessions (preview)
3535

3636
For scalability, Azure Cognitive Search distributes each index horizontally through a sharding process, which means that portions of an index are physically separate.
3737

@@ -40,13 +40,21 @@ By default, the score of a document is calculated based on statistical propertie
4040
If you prefer to compute the score based on the statistical properties across all shards, you can do so by adding *scoringStatistics=global* as a [query parameter](https://docs.microsoft.com/rest/api/searchservice/search-documents) (or add *"scoringStatistics": "global"* as a body parameter of the [query request](https://docs.microsoft.com/rest/api/searchservice/search-documents)).
4141

4242
```http
43-
GET https://[service name].search.windows.net/indexes/[index name]/docs?scoringStatistics=global
43+
GET https://[service name].search.windows.net/indexes/[index name]/docs?scoringStatistics=global&api-version=2019-05-06-Preview&search=[search term]
4444
Content-Type: application/json
45-
api-key: [admin key]
45+
api-key: [admin or query key]
4646
```
47+
Using scoringStatistics will ensure that all shards in the same replica provide the same results. That said, different replicas may be slightly different from one another as they are always getting updated with the latest changes to your index. In some scenarios, you may want your users to get more consistent results during a "query session". In such scenarios, you can provide a `sessionId` as part of your queries. The `sessionId` is a unique string that you create to refer to a unique user session.
48+
49+
```http
50+
GET https://[service name].search.windows.net/indexes/[index name]/docs?sessionId=[string]&api-version=2019-05-06-Preview&search=[search term]
51+
Content-Type: application/json
52+
api-key: [admin or query key]
53+
```
54+
As long as the same `sessionId` is used, a best-effort attempt will be made to target the same replica, increasing the consistency of results your users will see.
4755

4856
> [!NOTE]
49-
> An admin api-key is required for the `scoringStatistics` parameter.
57+
> 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.
5058
5159
## Similarity ranking algorithms
5260

0 commit comments

Comments
 (0)