[英]Unescape search results with django haystack and elasticsearch
I'm using django-haystack with elasticsearch backend. 我正在将django-haystack与elasticsearch后端一起使用。 The data contains names of books that may contain special characters like
&
, '
or ""
. 数据包含可能包含特殊字符(例如
&
, '
或""
的书名。 The indexed data escapes these characters and the search results shows the escaped data. 索引数据转义了这些字符,搜索结果显示了转义的数据。 How do I tell haystack or elasticsearch to
我如何告诉干草堆或elasticsearch
Here's 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)
In your template you can use filters and tags like: 在模板中,您可以使用过滤器和标签,例如:
{% autoescape on %}
{{ object.name }}
{% endautoescape %}
or 要么
{{ object.name|striptags }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.