Skip to content

Commit a5ef68d

Browse files
author
afoucret
committed
Update the doc.
1 parent 54e1ab7 commit a5ef68d

File tree

4 files changed

+42
-33
lines changed

4 files changed

+42
-33
lines changed

docs/reference/query-languages/esql/_snippets/commands/examples/rerank.csv-spec/combine.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ FROM books METADATA _score
55
| WHERE MATCH(description, "hobbit") OR MATCH(author, "Tolkien")
66
| SORT _score DESC
77
| LIMIT 100
8-
| RERANK rerank_score = "hobbit" ON description, author WITH { "inference_id" : "test_reranker" }
8+
| RERANK rerank_score = "hobbit" ON title, description WITH { "inference_id" : "test_reranker" }
99
| EVAL original_score = _score, _score = rerank_score + original_score
1010
| SORT _score
1111
| LIMIT 3
12-
| KEEP title, original_score, rerank_score, _score
1312
```
1413

15-
| title:text | _score:double | rerank_score:double | rerank_score:double |
16-
| --- | --- | --- | --- |
17-
| Poems from the Hobbit | 4.012462615966797 | 0.001396648003719747 | 0.001396648003719747 |
18-
| The Lord of the Rings - Boxed Set | 3.768855094909668 | 0.0010020040208473802 | 0.001396648003719747 |
19-
| Return of the King Being the Third Part of The Lord of the Rings | 3.6248698234558105 | 9.000900317914784E-4 | 0.001396648003719747 |
14+
| title:text | _score:double | rerank_score:double |
15+
| --- | --- | --- |
16+
| The Lord of the Rings Poster Collection: Six Paintings by Alan Lee (No. 1) | 0.7976278 | 0.125 |
17+
| A Middle English Reader and Vocabulary | 1.043297 | 0.07692308 |
18+
| FINAL WITNESS | 1.405817 | 0.07692308 |
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
% This is generated by ESQL's AbstractFunctionTestCase. Do not edit it. See ../README.md for how to regenerate it.
2+
3+
```esql
4+
FROM books
5+
| WHERE MATCH(title, "return")
6+
| RERANK "Tolkien" ON TOP_SNIPPETS(description, "Tolkien", { "num_snippets": 3, "num_words": 25 }) WITH { "inference_id" : "test_reranker" }
7+
```
8+
9+
| book_no:keyword | title:text | _score:double |
10+
| --- | --- | --- |
11+
| 2714 | Return of the King Being the Third Part of The Lord of the Rings | 0.007092198356986046 |
12+
| 7350 | Return of the Shadow | 0.012500000186264515 |

docs/reference/query-languages/esql/_snippets/commands/examples/rerank.csv-spec/two-queries.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ FROM books METADATA _score
66
| SORT _score DESC
77
| LIMIT 100
88
| RERANK rerank_score = "hobbit" ON description, author WITH { "inference_id" : "test_reranker" }
9-
| SORT rerank_score
9+
| SORT rerank_score DESC, book_no DESC
1010
| LIMIT 3
11-
| KEEP title, _score, rerank_score
1211
```
1312

1413
| title:text | _score:double | rerank_score:double |
1514
| --- | --- | --- |
16-
| Return of the Shadow | 3.4218082427978516 | 5.740527994930744E-4 |
17-
| Return of the King Being the Third Part of The Lord of the Rings | 2.8398752212524414 | 9.000900317914784E-4 |
18-
| The Lays of Beleriand | 1.5629040002822876 | 9.36329597607255E-4 |
15+
| The Lord of the Rings Poster Collection: Six Paintings by Alan Lee (No. 1) | 0.7976278066635132 | 0.125 |
16+
| A Middle English Reader and Vocabulary | 1.043297290802002 | 0.07692307978868484 |
17+
| FINAL WITNESS | 1.4058171510696411 | 0.07692307978868484 |

docs/reference/query-languages/esql/_snippets/commands/layout/rerank.md

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ stack: preview 9.2.0
77
The `RERANK` command uses an inference model to compute a new relevance score
88
for an initial set of documents, directly within your ES|QL queries.
99

10-
:::::{important}
11-
**RERANK processes each row through an inference model, which impacts performance and costs.**
10+
::::{tab-set}
1211

13-
::::{applies-switch}
12+
:::{tab-item} 9.3.0+
1413

15-
:::{applies-item} stack: ga 9.3+
16-
17-
`RERANK` automatically limits processing to **1000 rows by default** to prevent accidental high consumption. This limit is applied before the `RERANK` command executes.
14+
Starting in version 9.3.0, `RERANK` automatically limits processing to **1000
15+
rows by default** to prevent accidental high consumption. This limit is applied
16+
before the `RERANK` command executes.
1817

1918
If you need to process more rows, you can adjust the limit using the cluster setting:
2019
```
@@ -37,7 +36,7 @@ PUT _cluster/settings
3736
```
3837
:::
3938

40-
:::{applies-item} stack: ga =9.2
39+
:::{tab-item} 9.2.x
4140

4241
No automatic row limit is applied. **You should always use `LIMIT` before or after `RERANK` to control the number of documents processed**, to avoid accidentally reranking large datasets which can result in high latency and increased costs.
4342

@@ -52,7 +51,6 @@ FROM books
5251
:::
5352

5453
::::
55-
:::::
5654

5755
**Syntax**
5856

@@ -108,36 +106,31 @@ necessary.
108106

109107
How you increase the timeout depends on your deployment type:
110108

111-
::::::{applies-switch}
112-
113-
:::::{applies-item} ess:
109+
::::{tab-set}
110+
:::{tab-item} {{ech}}
114111

115112
* You can adjust {{es}} settings in
116113
the [Elastic Cloud Console](docs-content://deploy-manage/deploy/elastic-cloud/edit-stack-settings.md)
117114
* You can also adjust the `search.default_search_timeout` cluster setting
118115
using [Kibana's Advanced settings](kibana://reference/advanced-settings.md#kibana-search-settings)
116+
:::
119117

120-
:::::
121-
122-
:::::{applies-item} self:
118+
:::{tab-item} Self-managed
123119

124120
* You can configure at the cluster level by setting
125121
`search.default_search_timeout` in `elasticsearch.yml` or updating
126122
via [Cluster Settings API](https://www.elastic.co/docs/api/doc/elasticsearch/operation/operation-cluster-put-settings)
127123
* You can also adjust the `search:timeout` setting
128124
using [Kibana's Advanced settings](kibana://reference/advanced-settings.md#kibana-search-settings)
129125
* Alternatively, you can add timeout parameters to individual queries
126+
:::
130127

131-
:::::
132-
133-
:::::{applies-item} serverless:
128+
:::{tab-item} {{serverless-full}}
134129

135130
* Requires a manual override from Elastic Support because you cannot modify
136131
timeout settings directly
137-
138-
:::::
139-
140-
::::::
132+
:::
133+
::::
141134

142135
If you don't want to increase the timeout limit, try the following:
143136

@@ -165,3 +158,9 @@ Combine the original score with the reranked score:
165158

166159
:::{include} ../examples/rerank.csv-spec/combine.md
167160
:::
161+
162+
Rerank using snippets extracted from the document with the `TOP_SNIPPETS`
163+
function:
164+
165+
:::{include} ../examples/rerank.csv-spec/rerank-top-snippets.md
166+
:::

0 commit comments

Comments
 (0)