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

ISO 8601 date with timezone fails to parse without doublequotes #96

Open
chkp-shacharah opened this issue Jun 13, 2023 · 1 comment
Open

Comments

@chkp-shacharah
Copy link

Hi,

I'm experiencing errors parsing lucene strings that refer to a date-time value with timezone that is not wrapped with double-quotes. See for example:

>>> from luqum.parser import parser
>>> condition_tree = parser.parse('time:["2023-06-13T04:51:28+00:00" TO now]') # <--- WORKS
>>> condition_tree = parser.parse('time:[2023-06-13T04:51:28+00:00 TO now]')  # <-- FAILS 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/var/lang/lib/python3.8/site-packages/ply/yacc.py", line 333, in parse
    return self.parseopt_notrack(input, lexer, debug, tracking, tokenfunc)
  File "/var/lang/lib/python3.8/site-packages/ply/yacc.py", line 1201, in parseopt_notrack
    tok = call_errorfunc(self.errorfunc, errtoken, self)
  File "/var/lang/lib/python3.8/site-packages/ply/yacc.py", line 192, in call_errorfunc
    r = errorfunc(token)
  File "/var/lang/lib/python3.8/site-packages/luqum/parser.py", line 357, in p_error
    raise ParseSyntaxError("Syntax error in input : %s at %s!" % (error, pos))
luqum.exceptions.ParseSyntaxError: Syntax error in input : unexpected  ':' at position 28!

I can surely try to workaround it with patching the input and wrapping it with double-quotes, but since Elasticsearch accepts this as is - I wonder if this is a real bug that can be fixed here.
https://www.elastic.co/guide/en/elasticsearch/reference/7.10/query-dsl-query-string-query.html#query-string-top-level-params

time_zone
(Optional, string) Coordinated Universal Time (UTC) offset or IANA time zone used to convert date values in the query string to UTC.

Valid values are ISO 8601 UTC offsets, such as +01:00 or -08:00, and IANA time zone IDs, such as America/Los_Angeles.

@alexgarel
Copy link
Member

Hi @shachar-av, thanks for bug report. Would you be able to propose a PR ?

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