Django Full-Text Search with multiple words

前端 未结 2 581
予麋鹿
予麋鹿 2021-01-18 17:15

This isn\'t really a complex problem (to my knowledge).

I know in MongoDB you can feed in a string and it automatically tokenizes and performs full-text search using

相关标签:
2条回答
  • 2021-01-18 17:56

    To perform Full Text Search with Django you have to combine using GiN index with SearchVector.
    Here is full working example what I used somewhere. It works also on 2+ words in a query and searches them in 3 fields.

    0 讨论(0)
  • 2021-01-18 17:56

    You can use more than one word in SearchQuery. You can even get rid of SearchQuery if you don't need to search by logical combination of terms:

    Entry.objects.annotate(
         search=SearchVector('body_text'),
    ).filter(search="Multiple words query")
    
    0 讨论(0)
提交回复
热议问题