From 3589a135ef7f8d80bb4e218dcfc4d11f7e773eda Mon Sep 17 00:00:00 2001 From: GoodBai Date: Tue, 27 Feb 2024 04:39:17 +0800 Subject: [PATCH] community: make `SET allow_experimental_[engine]_index` configurabe in vectorstores.clickhouse (#18107) ## Description & Issue While following the official doc to use clickhouse as a vectorstore, I found only the default `annoy` index is properly supported. But I want to try another engine `usearch` for `annoy` is not properly supported on ARM platforms. Here is the settings I prefer: ``` python settings = ClickhouseSettings( table="wiki_Ethereum", index_type="usearch", # annoy by default index_param=[], ) ``` The above settings do not work for the command `set allow_experimental_annoy_index=1` is hard-coded. This PR will make sure the experimental feature follow the `index_type` which is also consistent with Clickhouse's naming conventions. --- libs/community/langchain_community/vectorstores/clickhouse.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/community/langchain_community/vectorstores/clickhouse.py b/libs/community/langchain_community/vectorstores/clickhouse.py index 4b8628daf7a..816ccd2aaca 100644 --- a/libs/community/langchain_community/vectorstores/clickhouse.py +++ b/libs/community/langchain_community/vectorstores/clickhouse.py @@ -205,8 +205,8 @@ CREATE TABLE IF NOT EXISTS {self.config.database}.{self.config.table}( ) # Enable JSON type self.client.command("SET allow_experimental_object_type=1") - # Enable Annoy index - self.client.command("SET allow_experimental_annoy_index=1") + # Enable index + self.client.command(f"SET allow_experimental_{self.config.index_type}_index=1") self.client.command(self.schema) @property