params = []
        filter_clause = ""
        if filter is not None:
            conjuncts = []
            for key, val in filter.items():
                conjuncts.append("metadata->>%s=%s")
                params.append(key)
                params.append(val)
            filter_clause = "where " + " and ".join(conjuncts)
        sql = (
            f"select document, metadata::text, "
            f"pm_approx_squared_euclidean_distance(array{json.dumps(embedding)}"
            f"::float4[], embedding) as distance from"
            f" {self.table_name} {filter_clause} order by distance asc limit {k};"
        )
        self.cursor.execute(sql, tuple(params))
        self.conn.commit()
        return self.cursor.fetchall()
[docs]class Hologres(VectorStore):
    """`Hologres API` vector store.
    - `connection_string` is a hologres connection string.
    - `embedding_function` any embedding function implementing
        `langchain.embeddings.base.Embeddings` interface.
    - `ndims` is the number of dimensions of the embedding output.
    - `table_name` is the name of the table to store embeddings and data.
        (default: langchain_pg_embedding)
        - NOTE: The table will be created when initializing the store (if not exists)
            So, make sure the user has the right permissions to create tables.
    - `pre_delete_table` if True, will delete the table if it exists.
        (default: False)
        - Useful for testing.
    """
[docs]    def __init__(
        self,
        connection_string: str,
        embedding_function: Embeddings,
        ndims: int = ADA_TOKEN_COUNT,