OpenSearch
Last updated
Last updated
LangStream supports using OpenSearch as a vector database.
Learn more about performing vector search with OpenSearch in the
Only OpenSearch 2.x is officially supported.
Create a vector-database
resource in your configuration.yaml file. A single resource is bound to a single index.
username
is the AWS Access Key
password
is the AWS Secret Key
host
is the endpoint provided by AWS. e.g. for AWS OpenSearch serverless it looks like this: xxxx..aoss.amazonaws.com
region
is the AWS region. It has to match with the one used in the endpoint
To bind the application to the OpenSearch index creation at startup, you must use the opensearch-index
asset type.
You can configure settings
and mappings
as you prefer. Other configuration fields are not supported.
This is an example mixing normal fields with vector fields. The knn
plugin is required in the target OpenSearch instance.
Use the query-vector-db
agent with the following parameters to perform searches on the index created above :
You can use the '?' symbol as a placeholder for the fields.
The output-field
will contain the query result. The result is an array with the following elements:
id
: the document ID
document
: the document source
score
: the document score
index
: the index name
For example, if you want to keep only one relevant field from the first result, use the compute
agent after the search:
Use the vector-db-sink
agent to index data, with the following parameters:
The request will be flushed depending on flush-interval
and batch-size
parameters.
Refer to the documentation for the settings
field. Refer to the documentation for the mappings
field.
The query
is the body sent to OpenSearch. Refer to the to learn which parameters are supported. Note that the query will be executed on the configured index. Multi-index queries are not supported, but you can declare multiple datasources and query different indexes in the same application.
All indexing is performed using the Bulk operation. You can customize the with the bulk-parameters
property.
Check out the full configuration properties in the .