模糊搜索问题
来源:15-3 django实现elasticsearch的搜索建议 - 1
三肥牛元气
2018-12-22
class SearchSuggest(View):
def get(self, request):
key_words = request.GET.get('s','')
current_type = request.GET.get('s_type', '')
if current_type == "article":
re_datas = []
if key_words:
s = ArticleType.search()
s = s.suggest('my_suggest', key_words, completion={
"field":"suggest",
"fuzzy":{
"fuzziness":2
},
"size": 10
})
suggestions = s.execute_suggest()
for match in suggestions.my_suggest[0].options:
source = match._source
re_datas.append(source["title"])
return HttpResponse(json.dumps(re_datas), content_type="application/json")
这个地方代码跟您的一样,界面搜索pythno没东西,在Kibana中搜索倒是有结果
写回答
1回答
-
bobby
2018-12-24
这里运行有报错信息吗?
042018-12-28
相似问题