Explorer
Explorer copied to clipboard
Range query fails when using date strings
Summary
Looks like the Range query validation forces us to use integers, however the ES range queries also support various date formats that are passed along as a string. https://www.elastic.co/guide/en/elasticsearch/reference/7.17/query-dsl-range-query.html
Steps to Reproduce
- Prepare a new scout query
- add a Range query to your search
- if the Range query receives dates as strings in the definitions, Assert::numeric fails
Potential Changes
- Match the validation that ES does on their end
- Drop the Assert::numeric call / allow strings and just let ES respond with errors if any
I see, thanks for the good description!
Another solution might be to create a separate DateTimeRange syntax. Then we can use a Datetime class on the PHP side and convert it to the right format for ES at the last minute instead of passing (in)valid strings around.
What do you think?
I like that idea! Typically, I use Carbon but you'd prefer a datetime implementation, right?
Yes, I'd prefer the native implementation!