Skip to content

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

@chkp-shacharah

Description

@chkp-shacharah

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions