Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range query fails when using date strings #180

Open
a-drew opened this issue Mar 24, 2023 · 3 comments
Open

Range query fails when using date strings #180

a-drew opened this issue Mar 24, 2023 · 3 comments

Comments

@a-drew
Copy link
Contributor

a-drew commented Mar 24, 2023

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

  1. Prepare a new scout query
  2. add a Range query to your search
  3. 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
@Jeroen-G
Copy link
Owner

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?

@a-drew
Copy link
Contributor Author

a-drew commented Mar 25, 2023

I like that idea! Typically, I use Carbon but you'd prefer a datetime implementation, right?

@Jeroen-G
Copy link
Owner

Yes, I'd prefer the native implementation!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants