0

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.

Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
rozap
  • 621
  • 1
  • 4
  • 13

1 Answers1

1

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.

Tom Gruner
  • 9,635
  • 1
  • 20
  • 26
  • You're right about that - however, I don't think there is a way to change the gram size with the setup I outlined above. I ended up switching to elastic search which is much more open to tweaking (or at least better documented). ES + Haystack has solved my problem. – rozap Apr 05 '13 at 16:42