POST /_bulk?pipeline=remote_embedding&refresh
{ "index": { "_index": "remote_sementic", "_id": 1 } }
{ "content": "Carson City is the capital city of the American state of Nevada."}
{ "index": { "_index": "remote_sementic", "_id": 2 } }
{ "content": "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan."}
{ "index": { "_index": "remote_sementic", "_id": 3 } }
{ "content": "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district."}
{ "index": { "_index": "remote_sementic", "_id": 4 } }
{ "content": "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states."}
{ "index": { "_index": "remote_sementic", "_id": 5 } }
{ "content": "Hello world."}
PUT _search/pipeline/remote_embedding
{
"description": "Pipeline for embedding query AND reranking with a cross-encoder",
"request_processors": [
{
"remote_embedding": {
"remote_config": {
"method": "POST",
"url": "xxx",
"params": {},
"headers": {
"Content-Type": "application/json"
},
"advance_request_body": {
"model": "zzz"
}
}
}
}
]
}
执行如下命令查询数据。
GET remote_sementic/_search?search_pipeline=remote_embedding
{
"_source": "content",
"query": {
"remote_neural": {
"content_knn": {
"query_text": "What is the capital of the United States?",
"k": 10
}
}
}
}
POST /_bulk?pipeline=sparse_encoding&refresh
{ "index": { "_index": "remote_sementic", "_id": 1 } }
{ "content": "Carson City is the capital city of the American state of Nevada."}
{ "index": { "_index": "remote_sementic", "_id": 2 } }
{ "content": "The Commonwealth of the Northern Mariana Islands is a group of islands in the Pacific Ocean. Its capital is Saipan."}
{ "index": { "_index": "remote_sementic", "_id": 3 } }
{ "content": "Washington, D.C. (also known as simply Washington or D.C., and officially as the District of Columbia) is the capital of the United States. It is a federal district."}
{ "index": { "_index": "remote_sementic", "_id": 4 } }
{ "content": "Capital punishment (the death penalty) has existed in the United States since beforethe United States was a country. As of 2017, capital punishment is legal in 30 of the 50 states."}
{ "index": { "_index": "remote_sementic", "_id": 5 } }
{ "content": "Hello world."}
PUT _search/pipeline/sparse_encoding
{
"description": "Pipeline for embedding query AND reranking with a cross-encoder",
"request_processors": [
{
"sparse_encoding": {
"remote_config": {
"method": "POST",
"url": "xxx",
"params": {},
"headers": {
"Content-Type": "application/json"
},
"advance_request_body": {
"model": "zzz"
}
}
}
}
]
}
执行如下命令查询数据。
GET remote_sementic/_search?search_pipeline=sparse_encoding
{
"_source": "content",
"query": {
"remote_neural_sparse": {
"content_sparse": {
"query_text": "What is the capital of the United States?"
}
}
}
}
POST rerank-test/_doc/1
{
"text_representation": "Jacques loves fish. Fish make Jacques happy",
"text_representation2": "He also loves noodle."
}
POST rerank-test/_doc/2
{
"text_representation": "Fish like to eat plankton",
"text_representation2": "Bob loves fish very much."
}
从指定的字段中获取数据,并将这些数据和 OpenSearch 中查询的结果一起发送给远端服务进行重排序,以得出更符合需求的最终结果。
例如,您可以在 appending_contexts 中传入 ["I like fish.", "He likes fish too."]信息,这两个文本内容会和 OpenSearch 查询结果一同用于重排序。
2.9.0.0-24.10.31 及以上版本。
rerank_prompt
String
否
从查询结果的指定字段中先获取相关数据并进行格式化调整,再将格式化后的结果发送到远程的服务端进行重排序。
例如,您可以在 rerank_prompt 中传入 This is {{text1}} \n That is {{text2}} Ending. 信息,实例会从先查询结果指定的字段中获取相应的值来替换 text1 和 text2,并将格式化后的结果进行重排序。