1. Lucene.Net
  2. LUCENENET-423

QueryParser differences between Java and .NET when parsing range queries involving dates


    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: Lucene.Net 2.9.2, Lucene.Net 2.9.4, Lucene.Net 2.9.4g
    • Fix Version/s: Lucene.Net 3.0.3
    • Component/s: None
    • Labels:


      When trying to do a RangeQuery that uses dates in a certain format, .NET behaves differently from its Java counterpart. The code is the same between them, but as far as I can tell, it appears that it is a difference in the way Java parses dates vs how .NET parses dates. To reproduce:

      var queryParser = new QueryParser(Lucene.Net.Util.Version.LUCENE_29, "FullText", new StandardAnalyzer(Lucene.Net.Util.Version.LUCENE_29));
      var query = queryParser.Parse("Field:[2001-01-17 TO 2001-01-20]");

      You'll notice that query looks like the old DateField format (eg "0g1d64542"). If you do the same query in Java (or Luke), you'll notice the query gets parsed as if it were a RangeQuery of string. AFAIK, Java cannot parse a string formatted in that way. If you change the string to use / instead of - in the java, you'll get one that uses DateResolutions and DateTools.DateToString().

      It seems an appropriate fix for this, if we wanted to keep this behavior similar to Java, would be to write our own DateTime parser that behaved the same way to Java's parser.

        Issue Links


          Christopher Currens created issue -
          Christopher Currens made changes -
          Field Original Value New Value
          Summary QueryParser differences between Java and .NET QueryParser differences between Java and .NET when parsing range queries involving dates
          Fix Version/s Lucene.Net 3.0.3 [ 12316215 ]
          Christopher Currens made changes -
          Link This issue is related to LUCENENET-478 [ LUCENENET-478 ]
          Christopher Currens made changes -
          Status Open [ 1 ] Closed [ 6 ]
          Resolution Fixed [ 1 ]


            • Assignee:
              Christopher Currens
            • Votes:
              0 Vote for this issue
              0 Start watching this issue


              • Created: