lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Busch (JIRA)" <>
Subject [jira] Updated: (LUCENE-732) Use DateTools instead of deprecated DateField in QueryParser
Date Tue, 05 Dec 2006 00:00:22 GMT
     [ ]

Michael Busch updated LUCENE-732:

    Attachment: queryparser_datetools2.patch

This new patch contains the changes suggested by Hoss:
- by default the QueryParser uses DateField to format dates for all fields
- if a date resolution has been set using void setDateResolution(DateTools.Resolution) then
DateTools is used for all fields with the given resolution
- if a field specific date resolution has been set using setDateResolution(String, DateTools.Resolution)
then DateTools is used for the given field with the given date resolution; other fields are
not affected

So with this patch the behaviour of QueryParser does not change unless either setDateResolution(DateTools.Resolution)
or setDateResolution(String, DateTools.Resolution) have been called.

> Use DateTools instead of deprecated DateField in QueryParser
> ------------------------------------------------------------
>                 Key: LUCENE-732
>                 URL:
>             Project: Lucene - Java
>          Issue Type: Improvement
>          Components: QueryParser
>            Reporter: Michael Busch
>         Assigned To: Michael Busch
>            Priority: Minor
>         Attachments: queryparser_datetools.patch, queryparser_datetools2.patch
> The QueryParser currently uses the deprecated class DateField to create RangeQueries
with date values. However, most users probably use DateTools to store date values in their
indexes, because this is the recommended way since DateField has been deprecated. In that
case RangeQueries with date values produced by the QueryParser won't work with those indexes.
> This patch replaces the use of DateField in QueryParser by DateTools. Because DateTools
can produce date values with different resolutions, this patch adds the following methods
to QueryParser:
>   /**
>    * Sets the default date resolution used by RangeQueries for fields for which no
>    * specific date resolutions has been set. Field specific resolutions can be set
>    * with {@link #setDateResolution(String, DateTools.Resolution)}.
>    *  
>    * @param dateResolution the default date resolution to set
>    */
>   public void setDateResolution(DateTools.Resolution dateResolution);
>   /**
>    * Sets the date resolution used by RangeQueries for a specific field.
>    *  
>    * @param field field for which the date resolution is to be set 
>    * @param dateResolution date resolution to set
>    */
>   public void setDateResolution(String fieldName, DateTools.Resolution dateResolution);
> (I also added the corresponding getter methods).
> Now the user can set a default date resolution used for all fields or, with the second
method, field specific date resolutions.
> The initial default resolution, which is used if the user does not set a different resolution,
is DateTools.Resolution.DAY. 
> Please let me know if you think we should use a different resolution as default.
> I extended TestQueryParser to test this new feature.
> All unit tests pass.

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message