1

I am trying to implement search with Haystack and Whoosh in a Django project.

The CharField I am trying to index has data like something_like_this. But it won't show up in the search result if I search for 'something' or 'this. It only works if I search for 'something_like_this'. Is there anyway to search the keywords in the CharFiled?

All I can think of is to create another CharField, store the string without underscore of the original string and then index it. But that seems like stupid idea.

user1499532
  • 315
  • 1
  • 3
  • 10

1 Answers1

1

Make data_field a MultiValueField and implement the prepare_data_field method where you could do something like this:

prepare_data_field(self, obj):
    return obj.data_field.split('_')
Oliver
  • 11,857
  • 2
  • 36
  • 42