Django ORM中的LIKE查询 [英] LIKE query in Django ORM

查看:704
本文介绍了Django ORM中的LIKE查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用以下规则进行查询:
按单词顺序排列,其中包含尽可能接近开头的已建立字符串。这是真的吗?

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'])


推荐答案

SearchRank 是您问题的答案,希望您将django与postgreSQL结合使用,由于django文档中对此进行了很好的说明,因此我将不作解释。
这是它的链接:-
Django SearchRank

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

享受和欢乐:-)

这篇关于Django ORM中的LIKE查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆