问题
How can I make query, with rule: order by words, that contain founded string as close as possible to the beginning. Is it real?
For example:
search 'hi'
result:
hi all
hi cat
Peter, hi
I come to you and say hi
query = query & Q(name__contains=params['name'])
回答1:
SearchRank is the answer to your question, hope you are using django with postgreSQL, I will not explain as it is well explained in the django docs. Here is the link to it:- Django SearchRank
Enjoy and rejoice :-)
来源:https://stackoverflow.com/questions/46221508/like-query-in-django-orm