質問

皆様にお伝えしたくて書き込みを簡単Django用ユーザに文字列が入力できます。アプリケーションの検索を通じて、データベースのためこの文字列になります。

Entry.objects.filter(headline__contains=query)

このクエリカ海峡の前進ではあるがないものを人にな100%ょう。い展開を検索します。

from django.utils import stopwords

results = Entry.objects.filter(headline__contains=query)
if(!results):
    query = strip_stopwords(query)
    for(q in query.split(' ')):
        results += Entry.objects.filter(headline__contains=q)

たいと思い追加機能を追加。検索見逃さず、複数形は、普通homophones(音で綴り異なる),パークがあります。どうしてそうなっちゃうんですか迷った場合も内蔵Djangosクエリ言語です。な重要なく巨大なアルゴリズムを思ったよりずっと見ているだけでも内蔵しています。

よろしくお願のすべての答えなのです。

役に立ちましたか?

解決

djangos ormないこの動作のボックスが複数のプロジェクトを統合するdjango w/検索サービス:

っといい話などのオプション#2#3で使用しましたdjango-スフィンクスが多いので、とても嬉しい。

他のヒント

You could try using python's difflib module.

>>> from difflib import get_close_matches
>>> get_close_matches('appel', ['ape', 'apple', 'peach', 'puppy'])
['apple', 'ape']
>>> import keyword
>>> get_close_matches('wheel', keyword.kwlist)
['while']
>>> get_close_matches('apple', keyword.kwlist)
[]
>>> get_close_matches('accept', keyword.kwlist)
['except']

Problem is that to use difflib one must build a list of words from the database. That can be expensive. Maybe if you cache the list of words and only rebuild it once in a while.

Some database systems support a search method to do what you want, like PostgreSQL's fuzzystrmatch module. If that is your case you could try calling it.


edit:

For your new "requirement", well, you are out of luck. No, there is nothing built in inside django's query language.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top