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.

Trouble filtering on date

See original GitHub issue

I have an index called private_data, with documents such as exact.date, name, etc. The data type in exact.date is date.

My code right now is s = Search(using=client, index = ['private_data']).source(['exact.date']).query("match",date= (datetime.date.today()))

The problem is the format of the exact.date documents is for example 2018-07-02T06:55:55.569Z, whereas datetime is in the format month-day-year. Is datetime still the best option to use in this scenario?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
honzakralcommented, Jul 3, 2018

Because you are doing an exact match against the date value (== number of miliseconds since the epoch) so only the exact same date, down to a milisecond, would match. If you want the whole day you need to use the range query/filter:

s = s.filter('range', date={'gte': date.today(), 'lt': date.today() + timedelta(days=1)})
0reactions
honzakralcommented, Jul 11, 2018

@johnsiano match will always choose the appropriate way to match a field and since date is stored as a number, there can be no partial match so it requires an exact match. Same applies to keyword fields etc.

Scoring typically only makes sense for text fields.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Excel Not Grouping Dates in Filters? How to Fix It!
Reason 1: Grouping dates in filters is disabled · In Excel, go to File. · Click on Options (usually in the left bottom...
Read more >
Can't fix a problem filtering date - Microsoft Power BI Community
I'm facing a problem when trying to filter a date from a calendar table related to a fact table. Basically I've created a...
Read more >
Filter date problem - Power Platform Community - Microsoft
I am building what should be relatively easy. I am getting items then filtering by Odata however the filter on date doesn't seem...
Read more >
Why am I having trouble filtering by date and time using ...
I have a data frame, and I'm trying to keep records after 10:05 AM on 1/22/21. df1$`Date/Time Opened` <- as_datetime(df1$`Date/Time Opened`) ...
Read more >
Thread: Date Filter Problem - Excel Help Forum
It's simple, if the ORG Date is empty, Update Date is empty too, if not it display date from ORG Date. Only when...
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