def query(self, query: VectorStoreQuery, **kwargs: Any) -> VectorStoreQueryResult:
        """
        Query index for top k most similar nodes.

        Args:
            query.query_embedding (List[float]): query embedding
            query.similarity_top_k (int): top k most similar nodes

        """
        nodes = []
        similarities = []
        ids = []

        if query.filters is not None:
            # TODO: results from the metadata filter query
            _filter_string = self._build_metadata_filter_condition(query.filters)
            _ddb_query = f"""
            SELECT node_id, text, embedding, metadata_, score
            FROM (
                SELECT *, list_cosine_similarity(embedding, ?) AS score
                FROM {self.table_name}
                WHERE ?
            ) sq
            WHERE score IS NOT NULL
            ORDER BY score DESC LIMIT ?;
            """
            query_params = [
                query.query_embedding,
                _filter_string,
                query.similarity_top_k,
            ]
        else:
            _ddb_query = f"""
            SELECT node_id, text, embedding, metadata_, score
            FROM (
                SELECT *, list_cosine_similarity(embedding, ?) AS score
                FROM {self.table_name}
            ) sq
            WHERE score IS NOT NULL
            ORDER BY score DESC LIMIT ?;
            """
            query_params = [
                query.query_embedding,
                query.similarity_top_k,
            ]

        _final_results = []
        if self.database_name == ":memory:":
            _final_results = self._conn.execute(_ddb_query, query_params).fetchall()
        elif self._database_path is not None:
            with DuckDBLocalContext(self._database_path) as _conn:
                _final_results = _conn.execute(_ddb_query, query_params).fetchall()

        for _row in _final_results:
            node = self._table_row_to_node(_row)
            nodes.append(node)
            similarities.append(_row[4])
            ids.append(_row[0])

        return VectorStoreQueryResult(nodes=nodes, similarities=similarities, ids=ids)

        Query index for top k most similar nodes.

        Args:
            query.query_embedding (List[float]): query embedding
            query.similarity_top_k (int): top k most similar nodes

        
llama-index-integrations/vector_stores/llama-index-vector-stores-duckdb/llama_index/vector_stores/duckdb/base.py