[Fixed]-Names with dash does not work in django-haystack

1๐Ÿ‘

โœ…

ok based on your search index schema. You are using EdgeNGramField which tokenize everything that you give to it into token of size 2 and more.

For ex : if you new york it will tokenize and make sure your document matches to terms like ne, new, yo, yor and york. EdgeNGram fields are generally used for autosuggest as it during query and indexing time it tokenize the word into such forms.

You can change your schema to CharField. That way it will zo-zo will transform to zo zo which will match to Zo-zo on in your index.

class EventIndex(indexes.SearchIndex, indexes.Indexable):
    text = indexes.CharField(document=True, use_template=True)

to do a match like as you intend. It will only support exact word matches that way.

Create a seperate field if you intend to keep EdgeNGram Field.

๐Ÿ‘คBipul Jain

Leave a comment