Unescape search results with django haystack and elasticsearch

I am using django-haystack with elasticsearch support. The data contains book names that may contain special characters, such as & , ' or "" . Indexed data eludes these characters, and search results show escaped data. How will I tell the Senate or elasticsearch

  • disable shielding
    OR
  • unescape characters when I want to use the results in a context other than HTML, i.e. how is plain text?

Here is my code:

 #search_indexes.py class Book(indexes.SearchIndex, indexes.Indexable): text = indexes.EdgeNgramField(document=True, use_template=True) def get_model(self): return Book #template {{object.name}} #query SearchQuerySet().autocomplete(text=my_query) 
+1
source share
1 answer

In the template, you can use filters and tags, for example:

 {% autoescape on %} {{ object.name }} {% endautoescape %} 

or

 {{ object.name|striptags }} 
+1
source

All Articles