I am not a coder, so I would not be much help in solving this. However, I recommend incorporating Matt Chaput's Whoosh python package - https://pypi.python.org/pypi/Whoosh/ - to do the actual searching. Per the Whoosh documentation:
It lets you connect terms with AND or OR, eleminate terms with NOT, group terms together into clauses with parentheses, do range, prefix, and wilcard queries, and specify different fields to search.
You could let Whoosh handle all of the search logic, and then focus on the rest of your code.
I am not a coder, so I would not be much help in solving this. However, I recommend incorporating Matt Chaput's Whoosh python package - https:/ /pypi.python. org/pypi/ Whoosh/ - to do the actual searching. Per the Whoosh documentation:
It lets you connect terms with AND or OR, eleminate terms with NOT, group terms together into clauses with parentheses, do range, prefix, and wilcard queries, and specify different fields to search.
You could let Whoosh handle all of the search logic, and then focus on the rest of your code.