I used elasticsearch-dsl==5.2.0, elasticsearch==5.3.0and Django==1.8.15.
Django Model :
class Item(models.Model):
price = models.DecimalField(default=0)
def to_search(self):
return DocItem(
meta={'id': self.id},
price=self.price
)
DocType Class :
class DocItem(DocType):
price = Integer()
FacetedSearch Class :
class ItemSearch(FacetedSearch):
index = 'item'
doc_types = [DocItem, ]
fields = ['price']
When I need to search all the elements with price == 5.0, I do the following:
search = ItemSearch().search()
result = search.filter('match', price=5.0).execute()
Question
How can I search for all products with a price in the range: 1.0 <price <= 5.0?
source
share