I have an object with a notes field that says "WV Test Two"
I would like to have that come up when I search "WV," "Test", "Two", or a combination of any of those. I am using Haystack with the Whoosh backend. It seems whenever "WV" is included in the search, it returns nothing even if there's another keyword in there.
>>> from haystack.query import SearchQuerySet as sqs
>>> results = sqs().filter(content='wv')
>>> results
[]
>>> results = sqs().filter(content='wv test')
>>> results
[]
>>> results = sqs().filter(content='test') # this works
>>> results
[<SearchResult: drives.files ... ]
>>> results = sqs().filter(content='two') # this also works
>>> results
[<SearchResult: drives.files ... ]
>>> results = sqs().filter(content='test two') # as does this
>>> results
[<SearchResult: drives.files ... ]
>>> results = sqs().filter(content='wv two')
>>> results
[]
>>> results = sqs().filter(content='wv test two')
>>> results
[]
I'm assuming it's because it's only 2 characters. Is there any way to fix this? I would like all of those queries to include "WV Test Two."
class Drives(models.Model):
serial = models.CharField(primary_key=True, max_length=100)
notes = models.TextField(blank=True)
username = models.CharField(max_length=20, blank=True)
in my search_indexes.py:
class DrivesIndex(indexes.SearchIndex, indexes.Indexable):
text = indexes.NgramField(document=True, use_template=True)
drives_text.txt:
{{ object.serial }}
{{ object.notes }}