我正在尝试在商品搜索中进行多面弹性搜索。但是,由于缺少任何文档,所以我无法。我能够成功实现弹性搜索,但是无法进一步过滤结果。单击链接后,我想进一步过滤结果。例如,用户来搜索iPhone。我的结果可以正确显示,但是如果单击链接仅过滤iPhone 6s,我将如何实现?这是我的搜索功能。
def search(request):
q = request.GET.get('q')
brandarray=request.GET.getlist('brand')
print(brandarray)
if q:
q = request.GET.get('q', None)
client = Elasticsearch()
s = Search(using=client)
query1=Q("multi_match", query=q, fields=['brand_name', 'bodystyle','model_name','variant_descr','transmission','yom'])
s = s.query(query1)
total = s.count()
s= s[0:total]
cars = s.execute()
fromelastic="Y"
paginator = Paginator(cars, 100)
page = request.GET.get('page')
cars = paginator.get_page(page)
context = {
"cars" : cars,
"total_result" : total,
"fromelastic" : fromelastic,
}
return render(request, 'search/search_results.html', context)