Skip to content

Commit 56a19d4

Browse files
committed
Reverse order of RRF examples
1 parent fcb3193 commit 56a19d4

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

solutions/search/retrievers-examples.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -418,18 +418,25 @@ stack: ga 9.1
418418
419419
There's an even simpler way to execute a hybrid search though: We can use the [multi-field query format](elasticsearch://reference/elasticsearch/rest-apis/retrievers.md#multi-field-query-format), which allows us to query multiple fields without explicitly specifying inner retrievers.
420420
421-
The following example uses the multi-field query format to query the `text` and `text_semantic` fields.
421+
One of the major challenges with hybrid search is normalizing the scores across matches on all field types.
422422
Scores from [`text`](elasticsearch://reference/elasticsearch/mapping-reference/text.md) and [`semantic_text`](elasticsearch://reference/elasticsearch/mapping-reference/semantic-text.md) fields don't always fall in the same range, so we need to normalize the ranks across matches on these fields to generate a result set.
423423
For example, BM25 scores from `text` fields are unbounded, while vector similarity scores from `text_embedding` models are bounded between [0, 1].
424424
The multi-field query format [handles this normalization for us automatically](elasticsearch://reference/elasticsearch/rest-apis/retrievers.md#multi-field-field-grouping).
425425

426+
The following example uses the multi-field query format to query every field specified in the `index.query.default_field` index setting, which is set to `*` by default.
427+
This default value will cause the retriever to query every field that either:
428+
429+
- Supports term queries, such as `keyword` and `text` fields
430+
- Is a `semantic_text` field
431+
432+
In this example, that would translate to the `text`, `text_semantic`, `year`, `topic`, and `timestamp` fields.
433+
426434
```console
427435
GET /retrievers_example/_search
428436
{
429437
"retriever": {
430438
"rrf": {
431-
"query": "artificial intelligence",
432-
"fields": ["text", "text_semantic"]
439+
"query": "artificial intelligence"
433440
}
434441
}
435442
}
@@ -477,26 +484,25 @@ This returns the following response based on the final rrf score for each result
477484

478485
::::
479486

480-
We don't even need to specify the `fields` parameter when using the multi-field query format.
481-
If we omit it, the retriever will automatically query fields specified in the `index.query.default_field` index setting, which is set to `*` by default.
482-
This default value will cause the retriever to query every field that either:
483-
484-
- Supports term queries, such as `keyword` and `text` fields
485-
- Is a `semantic_text` field
486-
487-
In this example, that would translate to the `text`, `text_semantic`, `year`, `topic`, and `timestamp` fields.
487+
We can also use the `fields` parameter to explicitly specify the fields to query.
488+
The following example uses the multi-field query format to query the `text` and `text_semantic` fields.
488489

489490
```console
490491
GET /retrievers_example/_search
491492
{
492493
"retriever": {
493494
"rrf": {
494-
"query": "artificial intelligence"
495+
"query": "artificial intelligence",
496+
"fields": ["text", "text_semantic"]
495497
}
496498
}
497499
}
498500
```
499501

502+
::::{note}
503+
The `fields` parameter also accepts [wildcard field patterns](elasticsearch://reference/elasticsearch/rest-apis/retrievers.md#multi-field-wildcard-field-patterns).
504+
::::
505+
500506
This returns the following response based on the final rrf score for each result.
501507

502508
::::{dropdown} Example response
@@ -539,8 +545,6 @@ This returns the following response based on the final rrf score for each result
539545

540546
::::
541547

542-
See [wildcard field patterns](elasticsearch://reference/elasticsearch/rest-apis/retrievers.md#multi-field-wildcard-field-patterns) for more information about wildcard resolution.
543-
544548

545549
## Example: Linear retriever with the multi-field query format [retrievers-examples-linear-multi-field-query-format]
546550
```yaml {applies_to}

0 commit comments

Comments
 (0)