Django MySQL full text search

后端 未结 6 1638
终归单人心
终归单人心 2020-12-05 05:20

I need to implement full text search for my Django application, running MySQL as backend.

Let\'s say I\'ve got a model as follows:

class MyItem(model         


        
6条回答
  •  借酒劲吻你
    2020-12-05 05:35

    I don't know if it helps now but I've created a new Python Library for Django which supports MySQLs' and MariaDBs' native full-text search engine over one or multiple columns:

    You can have a look at it on the GitHub repository

    There's also a description how to install it, use it and how to create the FULLTEXT INDEX stuff via Django migrations (Django 1.7+).

    If you've configured the indexes and set the SearchManager for your model you should be able to run something like:

    Mymodel.objects.search('Something')
    Mymodel.objects.search('Somet*')
    Mymodel.objects.search('+Something -Awesome')
    

    Just wanted to update this topic because I didn't find an acceptable solution so far and it might help someone out there as well :)

    Cheers Domi

提交回复
热议问题