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 that string as a query.
However, in Django, I have yet to find similar functionality, and all of the examples I've seen have done something along the lines of:
from django.contrib.postgres.search import SearchQuery
query = SearchQuery('foo')
Is the reason people only use one word because SearchQuery can only use one word?
What I want to know is how to perform full-text search with multiple words. Is it as easy as doing
from django.contrib.postgres.search import SearchQuery
query = SearchQuery('foo and also bar')
? Or does it need to be more complicated than that?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With