I'm tring to understand how haystack search works.
I hava a model Order with field Order.no where the order number is stored in a form 'ABC/2013/11/1', 'ABC/2013/11/2' ...
I want to implement autocomplete on this field using Haystack with Whoosh backend (django-haystack 2.1.0, celery-haystack 0.7.2, Whoosh 2.5.5, Django 1.6). My search_index.py looks like this:
class OrderIndex(CelerySearchIndex, indexes.Indexable):
text = indexes.CharField(document=True, use_template=True)
name_auto = indexes.EdgeNgramField(model_attr='name')
def get_model(self):
return Order
When I try
SearchQuerySet().autocomplete(name_auto='ABC/2013')
I recieve both ABC/2013/11/1 and ABC/2013/11/2 and it's ok
When I try
SearchQuerySet().autocomplete(name_auto='ABC/2013/11')
I still recieve both ABC/2013/11/1 and ABC/2013/11/2 and it's also ok but when I try
SearchQuerySet().autocomplete(name_auto='ABC/2013/11/1')
I still recieve both ABC/2013/11/1 and ABC/2013/11/2 I don't understand why.
I also notice that when I change the number format for the whole project for '1/ABC/2013/10' ... query like
SearchQuerySet().autocomplete(name_auto='1/')
doesn't return any results and query like
SearchQuerySet().autocomplete(name_auto='1/ABC')
return both '1/ABC/2013/10' and '2/ABC/2013/10'.
Maybe I'm missing something related to numbers and/or special characters in Haystack queries/ search strings. Thanks for any help.