{"record":{"id":"998e7520559bf912","repo":"pathwaycom/pathway","slug":"currently-usearch-knn-index-is-supported-only-in","errorCode":null,"errorMessage":"Currently, usearch knn index is supported only in the as-of-now variant","messagePattern":"Currently, usearch 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":119,"sourceCode":"    expansion_search: int = 0\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, usearch knn index is supported only in the as-of-now variant\"\"\"\n        raise NotImplementedError(\n            \"Currently, usearch 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":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/stdlib/indexing/nearest_neighbors.py#L101-L137","documentation":"The USearch-backed KNN index in pathway.stdlib.indexing.nearest_neighbors only implements query_as_of_now: queries are answered against the index as of the current minibatch, without waiting for pending insertions to settle. Its query() method exists to satisfy the index interface but unconditionally raises NotImplementedError with this message.","triggerScenarios":"Calling .query(query_column, number_of_matches=..., metadata_filter=...) on a UsearchKNNIndex instance (built directly or via UsearchKnnFactory.build_inner_index / .build_index) instead of .query_as_of_now().","commonSituations":"Generic retrieval code that calls .query() on any index polymorphically; older Pathway examples that predate the as-of-now split; LLM app templates wired to the default query path.","solutions":["Switch the call to query_as_of_now(query_column, number_of_matches=...).","In polymorphic code, prefer query_as_of_now uniformly across indices.","If strict consistency of query() matters for your use case, track the Pathway changelog for USearch query() support."],"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":["Use query_as_of_now as the default call in all retrieval helpers.","Wrap index dispatch behind one internal function so the fallback lives in exactly one place."],"tags":["pathway","usearch","knn","vector-search","not-implemented"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}