aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Isaac2023-01-18 01:51:24 +0000
committerArun Isaac2023-01-18 01:51:24 +0000
commit16b99eef9b7ad16ff5eac1b71d6b81f97fc6fe66 (patch)
tree1fc01d7a74ecbc30612fbc526340be721cab5cef
parentf4eb5d21f33d0dc8449d9d326f01d0687472cf4d (diff)
downloadgenenetwork3-16b99eef9b7ad16ff5eac1b71d6b81f97fc6fe66.tar.gz
Tolerate WEIGHT operator in parsed search queries.
* gn3/api/search.py (remove_synteny_field): Tolerate WEIGHT operator in parsed search queries.
-rw-r--r--gn3/api/search.py5
1 files changed, 3 insertions, 2 deletions
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)])