Comments (6)
For ranges it's usually better to do a filter:
s = Search().filter('range', some_date_field={'gte': datetime.now(), 'lte': datetime(2010, 10, 9)})
This will then produce a filtered
query with the proper range filter definition.
from elasticsearch-dsl-py.
May I know why filter is better over query for date ranges?
from elasticsearch-dsl-py.
Filters are better because they are cached by default so will provide you with a significant speed increase compared to queries. Since ranges don't contribute much to the score it's always best to use a filtered query with a filter.
from elasticsearch-dsl-py.
Thanks for the info.
from elasticsearch-dsl-py.
If I still wanted to do a query, how would I do it?
from elasticsearch-dsl-py.
@gregpinero use the query
method instead of filter
:
s = Search().query('range', some_date_field={'gte': datetime.now(), 'lte': datetime(2010, 10, 9)})
from elasticsearch-dsl-py.
Related Issues (20)
- 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
- Fix version specifier syntax in dependency string HOT 6
- cannot import name 'ApiError' from 'elasticsearch.exceptions' HOT 4
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.