擅长:python、mysql、java
<p>编辑:刚刚注意到这是只写博士后的</p>
<p>显然在django 1.10<a href="https://docs.djangoproject.com/en/1.10/ref/contrib/postgres/search/#searchvector" rel="noreferrer">SearchVector</a>类中添加了。</p>
<p>文档中的用法:</p>
<blockquote>
<p>Searching against a single field is great but rather limiting. The Entry instances we’re searching belong to a Blog, which has a tagline field. To query against both fields, use a SearchVector:</p>
</blockquote>
<pre><code>>>> from django.contrib.postgres.search import SearchVector
>>> Entry.objects.annotate(
... search=SearchVector('body_text', 'blog__tagline'),
... ).filter(search='Cheese')
[<Entry: Cheese on Toast recipes>, <Entry: Pizza Recipes>]
</code></pre>