-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support alibaba cloud elasticsearch (#418)
* add aliyun elasticsearch * code reuse
- Loading branch information
1 parent
6a63416
commit 854278a
Showing
4 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
vectordb_bench/backend/clients/aliyun_elasticsearch/aliyun_elasticsearch.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from ..elastic_cloud.elastic_cloud import ElasticCloud | ||
from ..elastic_cloud.config import ElasticCloudIndexConfig | ||
|
||
|
||
class AliyunElasticsearch(ElasticCloud): | ||
def __init__( | ||
self, | ||
dim: int, | ||
db_config: dict, | ||
db_case_config: ElasticCloudIndexConfig, | ||
indice: str = "vdb_bench_indice", # must be lowercase | ||
id_col_name: str = "id", | ||
vector_col_name: str = "vector", | ||
drop_old: bool = False, | ||
**kwargs, | ||
): | ||
super().__init__( | ||
dim=dim, | ||
db_config=db_config, | ||
db_case_config=db_case_config, | ||
indice=indice, | ||
id_col_name=id_col_name, | ||
vector_col_name=vector_col_name, | ||
drop_old=drop_old, | ||
**kwargs, | ||
) | ||
|
19 changes: 19 additions & 0 deletions
19
vectordb_bench/backend/clients/aliyun_elasticsearch/config.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from enum import Enum | ||
from pydantic import SecretStr, BaseModel | ||
|
||
from ..api import DBConfig, DBCaseConfig, MetricType, IndexType | ||
|
||
|
||
class AliyunElasticsearchConfig(DBConfig, BaseModel): | ||
#: Protocol in use to connect to the node | ||
scheme: str = "http" | ||
host: str = "" | ||
port: int = 9200 | ||
user: str = "elastic" | ||
password: SecretStr | ||
|
||
def to_dict(self) -> dict: | ||
return { | ||
"hosts": [{'scheme': self.scheme, 'host': self.host, 'port': self.port}], | ||
"basic_auth": (self.user, self.password.get_secret_value()), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters