官术网_书友最值得收藏!

Adding full-text search to your blog

Now, you will add search capabilities to your blog. The Django ORM allows you to perform simple matching operations using, for example, the contains filter (or its case-insensitive version, icontains). You can use the following query to find posts that contain the word framework in their body:

from blog.models import Post
Post.objects.filter(body__contains='framework')

However, if you want to perform complex search lookups, retrieving results by similarity or by weighting terms, you will need to use a full-text search engine.

Django provides a powerful search functionality built on top of PostgreSQL full-text search features. The django.contrib.postgres module provides functionalities offered by PostgreSQL that are not shared by the other databases that Django supports. You can learn about PostgreSQL full-text search at https://www.postgresql.org/docs/10/static/textsearch.html.

Although Django is a database-agnostic web framework, it provides a  module that supports part of the rich feature set offered by PostgreSQL, not shared by other databases that Django supports.

主站蜘蛛池模板: 大方县| 湖州市| 大石桥市| 泸定县| 平江县| 常宁市| 玛沁县| 伽师县| 富源县| 沂源县| 兴海县| 泌阳县| 阳城县| 砚山县| 逊克县| 外汇| 峨眉山市| 临朐县| 台南市| 阳西县| 湘西| 城固县| 旬邑县| 汾阳市| 登封市| 香河县| 灌南县| 广丰县| 东方市| 屯昌县| 潼南县| 榆林市| 迭部县| 左云县| 明水县| 和顺县| 定远县| 于都县| 三门县| 逊克县| 神木县|