Merge "Search bars handle queries as if they have a * at the end"

This commit is contained in:
Zuul 2019-04-09 21:40:52 +00:00 committed by Gerrit Code Review
commit bb0fd27372
2 changed files with 7 additions and 2 deletions

View File

@ -1,6 +1,6 @@
# The order of packages is significant, because pip processes them in the order
# of appearance. Changing the order has an impact on the overall integration
# process, which may cause wedges in the gate later.
sphinx>=1.1.2
sphinx<2.0.0
sphinxcontrib-pecanwsme>=0.5
openstackdocstheme

View File

@ -29,7 +29,12 @@ class SqlAlchemySearchImpl(search_engine.SearchEngine):
def _build_fulltext_search(self, model_cls, query, q,
mode=FullTextMode.BOOLEAN):
return query.filter(FullTextSearch(q, model_cls, mode=mode))
boolean_search_operators = ['+', '-', '~', '<', '>']
if(q[0] in boolean_search_operators or (q[0] == '"' and q[-1] == '"')
or q[-1] == '*'):
return query.filter(FullTextSearch(q, model_cls, mode=mode))
return query.filter(FullTextSearch(q + '*', model_cls, mode=mode))
def _apply_pagination(self, model_cls, query, marker=None,
offset=None, limit=None, sort_field='id',