From 16b99eef9b7ad16ff5eac1b71d6b81f97fc6fe66 Mon Sep 17 00:00:00 2001 From: Arun Isaac Date: Wed, 18 Jan 2023 01:51:24 +0000 Subject: Tolerate WEIGHT operator in parsed search queries. * gn3/api/search.py (remove_synteny_field): Tolerate WEIGHT operator in parsed search queries. --- gn3/api/search.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gn3/api/search.py') diff --git a/gn3/api/search.py b/gn3/api/search.py index 650208b..4ba2590 100644 --- a/gn3/api/search.py +++ b/gn3/api/search.py @@ -207,7 +207,7 @@ def remove_synteny_field(synteny_prefix: str, query: xapian.Query, parent_operator: int = xapian.Query.OP_AND) -> xapian.Query: """Return a new query with the synteny field removed.""" # Note that this function only supports queries that exclusively use the - # AND, OR, FILTER, RANGE and INVALID operators. + # AND, OR, FILTER, WEIGHT, RANGE and INVALID operators. # python xapian bindings do not expose xapian.Query.LEAF_TERM. This is # most likely a bug. leaf_type = 100 @@ -222,7 +222,8 @@ def remove_synteny_field(synteny_prefix: str, query: xapian.Query, else: raise ValueError("Unexpected operator in query", query.get_type()) # Recurse on non-leaf nodes with the AND, OR or FILTER operators as root. - elif query.get_type() in (xapian.Query.OP_AND, xapian.Query.OP_OR, xapian.Query.OP_FILTER): + elif query.get_type() in (xapian.Query.OP_AND, xapian.Query.OP_OR, + xapian.Query.OP_FILTER, xapian.Query.OP_SCALE_WEIGHT): return combine_queries(query.get_type(), *[remove_synteny_field(synteny_prefix, subquery, query.get_type()) for subquery in query_subqueries(query)]) -- cgit v1.2.3