{"record":{"id":"65f7269c6d7d87fe","repo":"pathwaycom/pathway","slug":"currently-brute-force-knn-index-is-supported-only","errorCode":null,"errorMessage":"Currently, brute force knn index is supported only in the as-of-now variant","messagePattern":"Currently, brute force knn index is supported only in the as-of-now variant","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"python/pathway/stdlib/indexing/nearest_neighbors.py","lineNumber":213,"sourceCode":"    metric: BruteForceKnnMetricKind\n    embedder: pw.UDF | None = None\n\n    # data column after applying embeddings. It is calculated during initialization and\n    # cannot be set in the constructor.\n    _data_column: pw.ColumnReference = field(init=False)\n\n    def __post_init__(self):\n        _data_column = _calculate_embeddings(self.data_column, self.embedder)\n        object.__setattr__(self, \"_data_column\", _data_column)\n\n    def query(\n        self,\n        query_column: pw.ColumnReference,\n        number_of_matches: pw.ColumnExpression | int = 3,\n        metadata_filter: pw.ColumnExpression | None = None,\n    ) -> pw.Table:\n        \"\"\"Currently, brute force knn index is supported only in the as-of-now variant\"\"\"\n        raise NotImplementedError(\n            \"Currently, brute force knn index is supported only in the as-of-now variant\"\n        )\n\n    @check_arg_types\n    def query_as_of_now(\n        self,\n        query_column: pw.ColumnReference,\n        number_of_matches: pw.ColumnExpression | int = 3,\n        metadata_filter: pw.ColumnExpression | None = None,\n    ) -> pw.Table:\n        index = self._data_column.table\n\n        query_column = _calculate_embeddings(query_column, self.embedder)\n        queries = query_column.table\n\n        check_default_knn_column_types(\n            self._data_column,\n            query_column,","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/stdlib/indexing/nearest_neighbors.py#L195-L231","documentation":"The brute-force KNN index (BruteForceKnnIndex) computes exact nearest neighbors but, like the USearch variant, only supports the as-of-now query flavor: results reflect the index state at the current minibatch without awaiting pending updates. The inherited-style query() method is declared for interface parity and always raises NotImplementedError.","triggerScenarios":"Calling .query(...) on a BruteForceKnnIndex (built directly or via BruteForceKnnFactory.build_inner_index()) rather than .query_as_of_now(...).","commonSituations":"Small-dataset pipelines that chose brute-force search for exactness, with call sites copied from generic index examples using .query(); shared retrieval wrappers that call .query() on whatever index object they receive.","solutions":["Call query_as_of_now(query_column, number_of_matches=...) instead.","Standardize all index call sites in the codebase on query_as_of_now for consistency across Pathway index types.","Track Pathway releases if blocking-consistent query() becomes available for brute-force KNN."],"exampleFix":"# before\nresults = index.query(query_table.query, number_of_matches=3)\n\n# after\nresults = index.query_as_of_now(query_table.query, number_of_matches=3)","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try:\n    res = index.query(query_col, number_of_matches=3)\nexcept NotImplementedError:\n    res = index.query_as_of_now(query_col, number_of_matches=3)","preventionTips":["Prefer query_as_of_now uniformly across BM25, USearch, and brute-force indices.","When adding a new index type, exercise both query paths in a smoke test so unsupported paths fail loudly in CI."],"tags":["pathway","knn","brute-force","vector-search","not-implemented"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}