You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Thomas Lemmé (JIRA)" <ji...@apache.org> on 2019/04/19 10:21:00 UTC

[jira] [Created] (LUCENE-8773) DateRangeField does not accept ISO 8601 date/time strings with more ore less than 3 decimal places

Thomas Lemmé created LUCENE-8773:
------------------------------------

             Summary: DateRangeField does not accept ISO 8601 date/time strings with more ore less than 3 decimal places
                 Key: LUCENE-8773
                 URL: https://issues.apache.org/jira/browse/LUCENE-8773
             Project: Lucene - Core
          Issue Type: Bug
    Affects Versions: trunk
         Environment: Solr running solr:7.7-alpine Docker image
            Reporter: Thomas Lemmé


*Context*: Solr running solr:7.7-alpine Docker image

*Steps to reproduce:*
 * create a DateRangeField field type 
{{<fieldType name="dateRange" class="solr.DateRangeField"/>}}
 * add a field to the schema:
{{<field name="openingHoursDates" type="dateRange" multiValued="true"/>}}
 * start & populate the core
 * Query the core with a filter query on the DateRangeField:
/select?&q.alt=*&defType=dismax&fq={!field f=openingHoursDates op=Contains}[2019-04-21T12:34:56.100Z TO *2019-04-21T12:34:56.1Z*]

*Expected:*
 * Solr returns matching documents

*Actual:*
 * ParseException is thrown & Solr returns Message "Couldn't parse date because: Improperly formatted datetime: 2019-04-21T12:34:56.1Z"

 

The timestamp has been created using DateTimeFormatter.ISO_DATE_TIME. I guess Solr should support Strings generated with the java datetime API.

 

*Stacktrace*:
{noformat}
2019-04-19 09:00:14.670 ERROR (qtp1543148593-18) [ x:snpindex] o.a.s.h.RequestHandlerBase org.apache.solr.common.SolrException: Couldn't parse date because: Improperly formatted datetime: 2019-04-21T12:34:56.1Z
at org.apache.solr.schema.DateRangeField.parseShape(DateRangeField.java:100)
at org.apache.solr.schema.DateRangeField.parseSpatialArgs(DateRangeField.java:134)
at org.apache.solr.schema.AbstractSpatialFieldType.getFieldQuery(AbstractSpatialFieldType.java:340)
at org.apache.solr.search.FieldQParserPlugin$1.parse(FieldQParserPlugin.java:45)
at org.apache.solr.search.QParser.getQuery(QParser.java:173)
at org.apache.solr.handler.component.QueryComponent.prepare(QueryComponent.java:207)
at org.apache.solr.handler.component.SearchHandler.handleRequestBody(SearchHandler.java:272)
at org.apache.solr.handler.RequestHandlerBase.handleRequest(RequestHandlerBase.java:199)
at org.apache.solr.core.SolrCore.execute(SolrCore.java:2551)
at org.apache.solr.servlet.HttpSolrCall.execute(HttpSolrCall.java:710)
at org.apache.solr.servlet.HttpSolrCall.call(HttpSolrCall.java:516)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:395)
at org.apache.solr.servlet.SolrDispatchFilter.doFilter(SolrDispatchFilter.java:341)
at org.eclipse.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1602)
at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:540)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
at org.eclipse.jetty.security.SecurityHandler.handle(SecurityHandler.java:548)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1588)
at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1345)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:480)
at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1557)
at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1247)
at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
at org.eclipse.jetty.server.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:220)
at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:126)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.rewrite.handler.RewriteHandler.handle(RewriteHandler.java:335)
at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
at org.eclipse.jetty.server.Server.handle(Server.java:502)
at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:364)
at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:260)
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.text.ParseException: Improperly formatted datetime: 2019-04-21T12:34:56.1Z
at org.apache.lucene.spatial.prefix.tree.DateRangePrefixTree.parseCalendar(DateRangePrefixTree.java:512)
at org.apache.lucene.spatial.prefix.tree.DateRangePrefixTree.parseUnitShape(DateRangePrefixTree.java:431)
at org.apache.lucene.spatial.prefix.tree.NumberRangePrefixTree.parseShape(NumberRangePrefixTree.java:188)
at org.apache.solr.schema.DateRangeField.parseShape(DateRangeField.java:97)
... 46 more
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 23
at java.lang.String.substring(String.java:1963)
at org.apache.lucene.spatial.prefix.tree.DateRangePrefixTree.parseCalendar(DateRangePrefixTree.java:507)
... 49 more
snpindex_1 |
2019-04-19 09:00:14.670 INFO (qtp1543148593-18) [ x:snpindex] o.a.s.c.S.Request [snpindex] webapp=/solr path=/select params={q.alt=*&defType=dismax&fq={!field+f%3DopeningHoursDates+op%3DContains}[2019-04-21T12:34:56.100Z+TO+2019-04-21T12:34:56.1Z]} status=400 QTime=5{noformat}
*Solution*:

The misconception in the current code is that it parses "milliseconds" but it's actually the decimal places of seconds.

I modified the parser to parse as many decimal places as available. The result is then normalized to milliseconds to fit the Java Calendar implementation.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org