Reputation: 939
I am using Django-haystack 2.4.1. I am trying to do a partial search for IntegerField
. I have a item_id
filed in my searchindex. For example I want to search 23456
, 2345
, 234,
23
, 2
all of these. This is not working with the query
SearchQuerySet().filter(item_id__icontains=234).models(MyModel)
Can anyone help me with this please.
Upvotes: 0
Views: 153
Reputation: 2014
In your search_indexes.py
the field that is your document field, should be EdgeNgramField
.
class ModelIndex(indexes.SearchIndex, indexes.Indexable):
indexed_text = indexes.EdgeNgramField(document=True, use_template=True)
And obviously you should update the index every time before making queries.
Upvotes: 0