سؤال

I have a django site running django-haystack with xapian as a back end. I got my autocomplete working, but it's giving back weird results. The results coming back from the searchqueryset are incomplete.

For example, I have the following data...

['test', 'test 1', 'test 2']

And if I type in 't', 'te', or 'tes' I get nothing back. However, if I type in 'test' I get back all of the results, as would be expected.

I have something looking like this...

results = SearchQuerySet().autocomplete(auto=q).values('auto')

And my search index looks like this...

class FacilityIndex(SearchIndex):
    text = CharField(document=True, use_template=True)
    created = DateTimeField(model_attr='created')
    auto = EdgeNgramField(model_attr='name')

    def get_model(self):
        return Facility

    def index_queryset(self):
        return self.get_model().objects.filter(created__lte=datetime.datetime.now())

Any tips are appreciated. Thanks.

هل كانت مفيدة؟

المحلول

A bit late, but you need to check the min ngram size that is being indexed. It is most likely 4 chars, so it won't match on anything with fewer chars than that. I am not a Xapian user though, so I don't know how to change this configuration option for that backend.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top