Skip to content

Commit fa77039

Browse files
authored
fix(community/clickhouse): support passthrough index param (#8592)
2 parents ff22c45 + 6dc674f commit fa77039

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

libs/langchain-community/src/vectorstores/clickhouse.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export interface ClickHouseLibArgs {
1717
username: string;
1818
password: string;
1919
indexType?: string;
20-
indexParam?: Record<string, number>;
20+
indexParam?: string | Record<string, number>;
2121
indexQueryParams?: Record<string, string>;
2222
columnMap?: ColumnMap;
2323
database?: string;
@@ -55,7 +55,7 @@ export class ClickHouseStore extends VectorStore {
5555

5656
private indexType: string;
5757

58-
private indexParam: Record<string, number>;
58+
private indexParam: string | Record<string, number>;
5959

6060
private indexQueryParams: Record<string, string>;
6161

@@ -225,11 +225,16 @@ export class ClickHouseStore extends VectorStore {
225225
private async initialize(dimension?: number): Promise<void> {
226226
const dim = dimension ?? (await this.embeddings.embedQuery("test")).length;
227227

228-
const indexParamStr = this.indexParam
229-
? Object.entries(this.indexParam)
228+
let indexParamStr = "";
229+
if (this.indexParam) {
230+
if (typeof this.indexParam === "string") {
231+
indexParamStr = this.indexParam;
232+
} else {
233+
indexParamStr = Object.entries(this.indexParam)
230234
.map(([key, value]) => `'${key}', ${value}`)
231-
.join(", ")
232-
: "";
235+
.join(", ");
236+
}
237+
}
233238

234239
const query = `
235240
CREATE TABLE IF NOT EXISTS ${this.database}.${this.table}(

0 commit comments

Comments
 (0)