From a0e40950febd2a8833a6fa6aa6f6e0f9ff0b0490 Mon Sep 17 00:00:00 2001 From: cybermaggedon Date: Wed, 22 Jul 2026 20:57:11 +0100 Subject: [PATCH] fix: apply all filters when querying rows by indexed field (#1056) The indexed query path only used a single index for the Cassandra lookup and ignored any remaining filters. This caused multi-field GraphQL queries to return results matching only the first indexed filter. Post-filter all results against the full filter set after the index lookup, and apply the limit after filtering to avoid short results. --- .../trustgraph/query/rows/cassandra/service.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/trustgraph-flow/trustgraph/query/rows/cassandra/service.py b/trustgraph-flow/trustgraph/query/rows/cassandra/service.py index 36315b15..b970dfa7 100644 --- a/trustgraph-flow/trustgraph/query/rows/cassandra/service.py +++ b/trustgraph-flow/trustgraph/query/rows/cassandra/service.py @@ -286,9 +286,6 @@ class Processor(FlowProcessor): """ params = [collection, schema_name, index_name, index_value] - if limit: - query += f" LIMIT {limit}" - try: pages = await async_execute_paged( self.session, query, params @@ -296,7 +293,12 @@ class Processor(FlowProcessor): for page in pages: for row in page: row_dict = dict(row.data) if row.data else {} - results.append(row_dict) + if self._matches_filters(row_dict, filters, row_schema): + results.append(row_dict) + if limit and len(results) >= limit: + break + if limit and len(results) >= limit: + break except Exception as e: logger.error(f"Failed to query rows: {e}", exc_info=True) raise