OpenSearch
LangStream supports using OpenSearch as a vector database.
Learn more about performing vector search with OpenSearch in the official documentation
Only OpenSearch 2.x is officially supported.
Connecting to OpenSearch
Create a vector-database
resource in your configuration.yaml file. A single resource is bound to a single index.
Connecting to AWS OpenSearch service
username
is the AWS Access Keypassword
is the AWS Secret Keyhost
is the endpoint provided by AWS. e.g. for AWS OpenSearch serverless it looks like this: xxxx..aoss.amazonaws.comregion
is the AWS region. It has to match with the one used in the endpoint
Declare an index as asset
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.
Refer to the settings documentation for the settings
field. Refer to the mappings documentation for the mappings
field.
Search
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 query
is the body sent to OpenSearch. Refer to the documentation 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.
The output-field
will contain the query result. The result is an array with the following elements:
id
: the document IDdocument
: the document sourcescore
: the document scoreindex
: 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:
Indexing
Use the vector-db-sink
agent to index data, with the following parameters:
All indexing is performed using the Bulk operation. You can customize the bulk parameters with the bulk-parameters
property.
The request will be flushed depending on flush-interval
and batch-size
parameters.
Configuration
Check out the full configuration properties in the API Reference page.
Last updated