-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace references to text_expansion with sparse_vector (#39)
- Loading branch information
Showing
6 changed files
with
62 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
|
||
|
||
|
||
Hybrid search between a semantic and lexical query can be achieved by using a | ||
`sub_searches` clause in your search request. In the `sub_searches` clause, | ||
provide a `text_expansion` query and a full-text query. Next to the | ||
`sub_searches` clause, also provide a `rank` clause with | ||
the `rrf` parameter to rank documents using reciprocal rank fusion. | ||
Hybrid search between a semantic and lexical query can be achieved by using retrievers in your search request. | ||
The following example uses retrievers to perform a match query and a sparse vector query, and rank them using RRF. | ||
|
||
```bash | ||
curl -X GET "${ES_URL}/my-index/_search" \ | ||
-H "Authorization: ApiKey ${API_KEY}" \ | ||
-H "Content-Type: application/json" \ | ||
-d' | ||
{ | ||
"sub_searches": [ | ||
{ | ||
"query": { | ||
"match": { | ||
"my_text_field": "the query string" | ||
} | ||
} | ||
}, | ||
{ | ||
"query": { | ||
"text_expansion": { | ||
"my_tokens": { | ||
"model_id": ".elser_model_2", | ||
"model_text": "the query string" | ||
"retriever": { | ||
"rrf": { | ||
"retrievers": [ | ||
{ | ||
"standard": { | ||
"query": { | ||
"match": { | ||
"my_text_field": "the query string" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"standard": { | ||
"query": { | ||
"sparse_vector": { | ||
"field": "my_tokens", | ||
"inference_id": "my-elser-endpoint", | ||
"query": "the query string" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"window_size": 50, | ||
"rank_constant": 20 | ||
} | ||
], | ||
"rank": { | ||
"rrf": {} | ||
} | ||
} | ||
' | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters