vector_database.mdx 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. ---
  2. title: '💾 Vector Database'
  3. ---
  4. We support `Chroma` and `Elasticsearch` as two vector database.
  5. `Chroma` is used as a default database.
  6. ### Elasticsearch
  7. In order to use `Elasticsearch` as vector database we need to use App type `CustomApp`.
  8. ```python
  9. import os
  10. from embedchain import CustomApp
  11. from embedchain.config import CustomAppConfig, ElasticsearchDBConfig
  12. from embedchain.models import Providers, EmbeddingFunctions, VectorDatabases
  13. os.environ["OPENAI_API_KEY"] = 'OPENAI_API_KEY'
  14. es_config = ElasticsearchDBConfig(
  15. # elasticsearch url or list of nodes url with different hosts and ports.
  16. es_url='http://localhost:9200',
  17. # pass named parameters supported by Python Elasticsearch client
  18. ca_certs="/path/to/http_ca.crt",
  19. basic_auth=("username", "password")
  20. )
  21. config = CustomAppConfig(
  22. embedding_fn=EmbeddingFunctions.OPENAI,
  23. provider=Providers.OPENAI,
  24. db_type=VectorDatabases.ELASTICSEARCH,
  25. es_config=es_config,
  26. )
  27. es_app = CustomApp(config)
  28. ```
  29. - Set `db_type=VectorDatabases.ELASTICSEARCH` and `es_config=ElasticsearchDBConfig(es_url='')` in `CustomAppConfig`.
  30. - `ElasticsearchDBConfig` accepts `es_url` as elasticsearch url or as list of nodes url with different hosts and ports. Additionally we can pass named paramaters supported by Python Elasticsearch client.