Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize order by relevance #22

Open
cod3licious opened this issue Jul 26, 2016 · 1 comment
Open

optimize order by relevance #22

cod3licious opened this issue Jul 26, 2016 · 1 comment

Comments

@cod3licious
Copy link

one thing i've noticed is that the ordering of the results is done by case which seems quite inefficient or at least if you don't have a limit on the number of search results would create a really large query string.
the problem i see: while i do want a limit on the number of search results i also have some other filters in my query before i apply the search, e.g. the document shouldn't be older than a few days. since whoosh doesn't pay attention to these other filters it might very well be that i set a whoosh limit of 10 but then i get 10 articles which are subsequently filtered out by my other condition, leaving me with nothing. therefore i would apply .limit(10) on the query afterwards. however then i still have the problem that the first 10 articles that are ordered by default might not be the ones i'm left with after the other filter conditions are applied and of course i would still like to have my final search results ordered. but with no limit, ordering all my results will result in this huge query as mentioned in the beginning.

i'm not sure what would be a good way to improve this, but flask-whooshalchemy overwrites the __iter__() method of the query class (https://github.com/gyllstromk/Flask-WhooshAlchemy/blob/master/flask_whooshalchemy.py#L60) which doesn't sound like such a bad idea?

@bkabrda
Copy link
Collaborator

bkabrda commented Jul 27, 2016

Overwriting the __iter__() method would certainly be an ideal solution, I was looking at WhooshAlchemy as well and I like it. The current solution is kind of simplistic and I agree it's far from ideal. I don't have time to work on this right now, but I'd gladly accept PR that would implement sorting via the __iter__() method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants