question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How do i make a range query/filter for a nested field using DSL?

See original GitHub issue

Tried:

query = query.filter('range', **{'field.name': {'lt': 1.22}})

always comes up with empty results

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
honzakralcommented, Dec 1, 2015

For nested fields you need to use nested filters:

query = query.filter('nested', path='field', filter=F('range', field__name={'lt': 1.22}))

Note also that you can use double underscore instead of . to avoid having to use the **{} construct.

Hope this helps.

3reactions
honzakralcommented, Feb 22, 2017

@siddhism you can either use python’s ** expansion (query.filter('match', **{"fs.mount_point": "/"})) or use the fact that elasticsearch-dsl will expand __ to dot: query.filter('match', fs__mount_point='/')

Read more comments on GitHub >

github_iconTop Results From Across the Web

Doing a Range Query over particular Nested Document
Is it possible to get only the document that has title: duration and their value is greater than 60.Value Property in the nested...
Read more >
Nested query | Elasticsearch Guide [8.5]
Wraps another query to search nested fields. The nested query searches nested field objects as if they were indexed as separate documents.
Read more >
Search DSL — Elasticsearch DSL 7.2.0 documentation
To make it easier, the Q shortcut (as well as the query , filter , and exclude methods on Search class) allows you...
Read more >
Deep Dive into Querying Elasticsearch. Filter vs Query. Full ...
The range query also works well with dates. Regexp, wildcard and prefix queries. Regexp query returns the documents in which fields match your ......
Read more >
Boolean queries - OpenSearch documentation
If you have multiple queries, all of them must match. ... Use the filter query to filter the results based on exact matches,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found