Skip to main content

Searching

Performing Queries

  • Single search queries are performed with the original _search endpoint by replacing the knn field with a gsi_knn field in the request body.

    note

    Remember to replace the vector field with your index's specific vector fields name.

  • Batch queries are performed with a custom endpoint and request body.

Single search query example:

POST <serverHostName>:9200/<indexName>/_search
{
"query": {
"gsi_knn": {
"field": "description_vector",
"vector": [
0.0015746655408293009,
0.025234133005142212,
0.0031481462065130472....
],
"topk": 2,
"prefilter": {
"sub_category": "Dress",
"source": "comsumer"
},
"filterOperator": "OR"
}
},
"size": 30
}

Batch of queries example:

POST <serverHostName>:9200/gsi/search/multiquery/<indexName>/<nameOfVectorField>
{
"queries": [
{
"vector": [
0.25973913073539734,
0.023432284593582153,
0.07090096920728683,
0.006839084904640913,
0.015795692801475525...
]
},
{
"vector": [
0.05060698837041855,
0,
0.04455435276031494,
0.0069176568649709225,
0.06633245199918747...
],
"prefilter": {
"description": "Siberian husky",
"image_url.keyword": "n02096585_6634.JPEG"
},
"filterOperator": "OR"
}
],
"topk": "2"
}