Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
Range query in Elasticsearch_dsl by integer field

I used elasticsearch-dsl==5.2.0, elasticsearch==5.3.0 and 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 items with price == 5.0, I do the next:

search = ItemSearch().search()
result = search.filter('match', price=5.0).execute()

Question:

How can I search all items with price in range: 1.0 < price <= 5.0 ?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can do it like this:

search = ItemSearch().search()
result = search.filter('range', price={'gt': 1, 'lte': 5.0}).execute()
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!