-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Open
Labels
Description
Describe the bug
I am running the following in OpenSearch 3.2.0. Executing the below query works fine with reranking but it fails inside search template.
PUT testindex/_doc/1
{
"content":"I like to play playstation"
}
PUT testindex/_doc/2
{
"content":"I am downloading opensearch"
}
PUT testindex/_doc/3
{
"content":"I would like to go to school"
}
PUT /_search/pipeline/my_pipeline
{
"description": "Pipeline for reranking with a cross-encoder",
"response_processors": [
{
"rerank": {
"ml_opensearch": {
"model_id": "zixilpwBeCNW-ZZWVSNk"
},
"context": {
"document_fields": [
"content"
]
}
}
}
]
}
GET testindex/_search
{
"search_pipeline":"my_pipeline",
"query": {
"query_string": {
"default_field": "content",
"query": "I"
}
},
"ext": {
"rerank": {
"query_context": {
"query_text": "school"
}
}
}
}
In the result, document 3 comes first.
When wrapping the query inside a search template, reranking does not take effect as shown in the below.
POST _scripts/play_search_template
{
"script": {
"lang": "mustache",
"source": """
{
"search_pipeline":"my_pipeline",
"query": {
"query_string": {
"default_field": "content",
"query": "I"
}
},
"ext": {
"rerank": {
"query_context": {
"query_text": "school"
}
}
}
}
""",
"params": {
}
}
}
GET testindex/_search/template
{
"id":"play_search_template"
}
Note that setting search pipeline in the body works fine as shown in the below example.
POST _scripts/play_search_template
{
"script": {
"lang": "mustache",
"source": """
{
"search_pipeline":{
"response_processors": [
{
"rerank": {
"ml_opensearch": {
"model_id": "zixilpwBeCNW-ZZWVSNk"
},
"context": {
"document_fields": [
"content"
]
}
}
}
]
},
"query": {
"query_string": {
"default_field": "content",
"query": "I"
}
},
"ext": {
"rerank": {
"query_context": {
"query_text": "school"
}
}
}
}
""",
"params": {
}
}
}
GET testindex/_search/template
{
"id":"play_search_template"
}
Related component
No response
To Reproduce
- Go to '...'
- Click on '....'
- Scroll down to '....'
- See error
Expected behavior
.
Additional Details
Plugins
Please list all plugins currently enabled.
Screenshots
If applicable, add screenshots to help explain your problem.
Host/Environment (please complete the following information):
- OS: [e.g. iOS]
- Version [e.g. 22]
Additional context
Add any other context about the problem here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
π New