如何实现 Haystack 搜索获取的自动完成
how to impliment Haystacksearch fetched autocomplete
我想在自动完成中实现抓取,这是我的自动完成功能
def autocomplete(request):
fetch_field = request.GET.get('fetch_field')
sqs = SearchQuerySet().autocomplete(
content_auto=request.GET.get(
'query',
''))[
:5]
s = []
for result in sqs:
d = {"value": result.title, "data": result.object.slug}
s.append(d)
output = {'suggestions': s}
print('hihi' ,output)
return JsonResponse(output)
现在我可以获取字段,但我不知道如何使用 SearchQuerySet 获取字段。
sqs = SearchQuerySet().filter(field_want_to_fetch = fetch_field ).autocomplete(
content_auto=request.GET.get(
'query',
''))[
:5]
用这个!!
我想在自动完成中实现抓取,这是我的自动完成功能
def autocomplete(request):
fetch_field = request.GET.get('fetch_field')
sqs = SearchQuerySet().autocomplete(
content_auto=request.GET.get(
'query',
''))[
:5]
s = []
for result in sqs:
d = {"value": result.title, "data": result.object.slug}
s.append(d)
output = {'suggestions': s}
print('hihi' ,output)
return JsonResponse(output)
现在我可以获取字段,但我不知道如何使用 SearchQuerySet 获取字段。
sqs = SearchQuerySet().filter(field_want_to_fetch = fetch_field ).autocomplete(
content_auto=request.GET.get(
'query',
''))[
:5]
用这个!!