- Newest
- Most votes
- Most comments
The issue you're experiencing with radial search not working in OpenSearch Serverless is likely due to the fact that OpenSearch Serverless currently does not support the radial search feature. Radial search, which allows you to search points in a vector space within a specified maximum distance or minimum score threshold, is a feature that was introduced in OpenSearch version 2.15 for provisioned domains.
However, OpenSearch Serverless may not have this feature implemented yet. Serverless offerings often lag behind in terms of feature parity with their provisioned counterparts.
To make your query work in OpenSearch Serverless, you'll need to modify it to use the standard k-nearest neighbor (k-NN) search instead of radial search. Here's how you can adjust your query:
- Replace the
max_distanceparameter withk(number of nearest neighbors to return). - Remove the
filtersection from within theknnquery (as it's not supported in this context).
Your modified query should look like this:
GET knn-index-test/_search
{
"query": {
"knn": {
"my_vector": {
"vector": [7.1, 8.3],
"k": 5
}
}
}
}
This query will return the 5 nearest neighbors to the given vector [7.1, 8.3].
If you need to filter results based on the price field, you can use a bool query to combine the k-NN search with a range filter:
GET knn-index-test/_search
{
"query": {
"bool": {
"must": [
{
"knn": {
"my_vector": {
"vector": [7.1, 8.3],
"k": 5
}
}
}
],
"filter": [
{
"range": {
"price": {
"gte": 1,
"lte": 5
}
}
}
]
}
}
}
This query will perform a k-NN search and then filter the results based on the price range.
Keep in mind that while this approach will work, it doesn't provide the exact functionality of radial search. You may need to retrieve more results (higher k value) and then post-process them in your application to achieve similar results to what radial search would provide.
For the most up-to-date information on feature availability in OpenSearch Serverless, it's recommended to check the official AWS documentation or contact AWS support.
Sources
Amazon OpenSearch Service now supports OpenSearch version 2.15 - AWS
Amazon OpenSearch Serverless - Amazon OpenSearch Service
