Reputation: 145
I am using ElasticSearch-DSL in my django application and the query returns only 10 rows. When I use size. I get an error "multi_match" query does not support size.
from django.shortcuts import render
from elasticsearch_dsl import Q
from elasticsearch_dsl.query import MultiMatch
# Create your views here.
from search.documents import CarDocument
from products.models import Products
def search(request):
q = request.GET.get('q')
if q:
#cars = CarDocument.search().query("match", model_name=q)
q = request.GET.get('q', None)
query1 = MultiMatch(query=q, fields=['product_make', 'bodystyle','model_name','variant','transmission','yom'])
s = CarDocument.search().query(query1)
cars = s.execute()
else:
cars = ''
return render(request, 'search/search.html', {'cars': cars})
Upvotes: 0
Views: 1117
Reputation: 113
With this, you shall get all records:
s = CarDocument.search().query(query1)
total = s.count()
s = s[0:total]
cars = s.execute()
Upvotes: 2
Reputation: 145
By default, it returns 10 data. If you want more than 10 data, like to get 50 data you can use CarDocument.search()[:50]
Upvotes: 1