35 lines
1.3 KiB
Plaintext
35 lines
1.3 KiB
Plaintext
---
|
|
title: '💾 Vector Database'
|
|
---
|
|
|
|
We support `Chroma` and `Elasticsearch` as two vector database.
|
|
`Chroma` is used as a default database.
|
|
|
|
### Elasticsearch
|
|
In order to use `Elasticsearch` as vector database we need to use App type `CustomApp`.
|
|
```python
|
|
import os
|
|
from embedchain import CustomApp
|
|
from embedchain.config import CustomAppConfig, ElasticsearchDBConfig
|
|
from embedchain.models import Providers, EmbeddingFunctions, VectorDatabases
|
|
|
|
os.environ["OPENAI_API_KEY"] = 'OPENAI_API_KEY'
|
|
|
|
es_config = ElasticsearchDBConfig(
|
|
# elasticsearch url or list of nodes url with different hosts and ports.
|
|
es_url='http://localhost:9200',
|
|
# pass named parameters supported by Python Elasticsearch client
|
|
ca_certs="/path/to/http_ca.crt",
|
|
basic_auth=("username", "password")
|
|
)
|
|
config = CustomAppConfig(
|
|
embedding_fn=EmbeddingFunctions.OPENAI,
|
|
provider=Providers.OPENAI,
|
|
db_type=VectorDatabases.ELASTICSEARCH,
|
|
es_config=es_config,
|
|
)
|
|
es_app = CustomApp(config)
|
|
```
|
|
- Set `db_type=VectorDatabases.ELASTICSEARCH` and `es_config=ElasticsearchDBConfig(es_url='')` in `CustomAppConfig`.
|
|
- `ElasticsearchDBConfig` accepts `es_url` as elasticsearch url or as list of nodes url with different hosts and ports. Additionally we can pass named parameters supported by Python Elasticsearch client.
|