Comments (6)
Hey @garyelephant as far as i understand you are trying to implement a range filter in dsl. You can do something like this:
s.filter('range', **{field_name: {"from": from_date, "to": to_date}})
In case you are trying to input the field name and date ranges from variables.
You can also replace lte and gte instead of from and to
from elasticsearch-dsl-py.
is this the only way ?
f = F({'range':{'@timestamp':{'gte':'now-1h','lte':'now'}}})
s = s.filter( f )
from elasticsearch-dsl-py.
You can use several ways - anything accepted by F
can also be passed in to .filter()
, you can also use the **{'@timestamp': {...}}
notation like this:
s = s.filter('range', **{'@timestamp': {'gte': ...}})
from elasticsearch-dsl-py.
Can elasticsearch-dsl create this nested structure automatically by pass simple params something like
s.filter( 'range', '@timestamp', gte='...', lte='...')
from elasticsearch-dsl-py.
Hmm, I like this approach for simple things but I am not sure it will be still clear for more complex structure and it might lead to confusion there - for example what if the structure is even more nested - either has multiple levels or multiple keys?
The biggest advantage of the current approach, as I see it, is that it's absolutely straightforward to use based on the JSON DSL (which is described in the elasticsearch docs) and no additional knowledge is needed, this might bring in more indirection.
I will leave the ticket open for now so we can have a discussion here and decide what we should do here.
from elasticsearch-dsl-py.
I still don't see how we could implement this consistently so I am closing the ticket.
from elasticsearch-dsl-py.
Related Issues (20)
- Version query parameter does not yield proper results HOT 1
- Error 429 - Too Many Requests /_search/scroll - how can I handle it? HOT 1
- How to set up persisting documents with indices that apply ILM policy. HOT 1
- elasticsearch.helpers.BulkIndexError: 1 document(s) failed to index. HOT 4
- How to add a mapping on the Document class HOT 1
- Missing TopMetrics aggregation
- Document use cases where mappings already exist (re Persistence) HOT 1
- Using/configuring pipelines for indices
- Support more advanced IndexTemplate use cases (ex. flexible routing)
- Deprecation warnings in elasticsearch 8.12.0 with current version 8.12.0 of this library HOT 9
- Unexpected outcome when combining queries HOT 2
- Issues with updating nested objects in Elasticsearch DSL within Django Rest Framework?
- Updating nested issue
- Trio support
- kNN as a query support
- ImportError: cannot import name 'AggsProxy' from 'elasticsearch_dsl.search' HOT 3
- Inconsistent handling of empty lists in Document partial updates. HOT 2
- Better support for sparse vectors and ELSER HOT 1
- Add support for defining ingest pipelines
- Enable Direct Access to `ConstantKeyword` from `elasticsearch_dsl `Module HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from elasticsearch-dsl-py.