- Newest
- Most votes
- Most comments
When querying vector data in OpenSearch that was created by Amazon Bedrock Knowledge Bases, you need to use the k-NN (k-nearest neighbors) query syntax rather than the neural query syntax you attempted.
For your specific case with embeddings generated by Amazon Titan Text Embeddings v2, you should use the knn query type in OpenSearch Dashboard's Dev Tools. The issue with your current query is that you're using the neural query type, which isn't compatible with how the vectors were stored in your index.
Try this query format instead:
GET bedrock-knowledge-base-default-index/_search
{
"size": 10,
"query": {
"knn": {
"bedrock-knowledge-base-default-vector": {
"vector": [VECTOR_VALUES_HERE],
"k": 10
}
}
}
}
However, there's a critical challenge here: you need to provide the actual vector values in the query. Since your vectors were generated by Amazon Titan Text Embeddings v2, you would need to generate the embedding for your search term "Sense and Sensibility" using the same model first.
This is why directly querying from OpenSearch Dashboard is difficult in this scenario - you need to generate the embedding vector for your query text first using the same Amazon Titan Text Embeddings v2 model that was used to create the Knowledge Base.
The recommended approach is to query your Knowledge Base through Amazon Bedrock's APIs rather than directly through OpenSearch Dashboard, as Bedrock will handle the embedding generation and vector search for you automatically.
If you still need to query directly from OpenSearch for debugging purposes, you would need to:
- Generate the embedding for your query text using Amazon Titan Text Embeddings v2
- Use the resulting vector in the knn query shown above
This explains why you're getting an error - the neural query syntax expects a different configuration than what your Bedrock Knowledge Base has set up in OpenSearch.
Sources
Querying vectors - Amazon Simple Storage Service
(Preview) Advanced search capabilities with an Amazon S3 vector engine - Amazon OpenSearch Service
Vector search - Amazon OpenSearch Service
Amazon Bedrock Knowledge Bases now supports Amazon OpenSearch Service Managed Cluster as vector store | Artificial Intelligence
Relevant content
asked 3 years ago

Thank you for your answer,
After generation of the embeddings, in Postman, using Amazon Titan Text Embeddings v2, with input:
the result contained a huge vector, that I used with the query specified in the answer, and SUCCESFULLY got 10 chunks from OpenSearch, with the maximum score for all of them of : 0.5543516 .
Does the low score means that OpenSearch could not find the themes from the book ?
Or should the Knowledge Base in Bedrock, in Test area, with US Nova Premier LLM, built the main themes with the chunks retrieved, while the invocation for Open Search should be a different question ? The overall response from the Test Area was :
Sorry, I am unable to assist you with this request.