Return-Path: Delivered-To: apmail-lucene-java-dev-archive@www.apache.org Received: (qmail 42918 invoked from network); 6 Dec 2006 22:39:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Dec 2006 22:39:48 -0000 Received: (qmail 58866 invoked by uid 500); 6 Dec 2006 22:39:53 -0000 Delivered-To: apmail-lucene-java-dev-archive@lucene.apache.org Received: (qmail 58833 invoked by uid 500); 6 Dec 2006 22:39:53 -0000 Mailing-List: contact java-dev-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: java-dev@lucene.apache.org Delivered-To: mailing list java-dev@lucene.apache.org Received: (qmail 58822 invoked by uid 99); 6 Dec 2006 22:39:53 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Dec 2006 14:39:53 -0800 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 06 Dec 2006 14:39:44 -0800 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 7C4EF7142BF for ; Wed, 6 Dec 2006 14:39:24 -0800 (PST) Message-ID: <4304278.1165444764506.JavaMail.jira@brutus> Date: Wed, 6 Dec 2006 14:39:24 -0800 (PST) From: "Hoss Man (JIRA)" To: java-dev@lucene.apache.org Subject: [jira] Commented: (LUCENE-732) Support DateTools in QueryParser In-Reply-To: <32411369.1164830721059.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org [ http://issues.apache.org/jira/browse/LUCENE-732?page=comments#action_12456242 ] Hoss Man commented on LUCENE-732: --------------------------------- +1 for queryparser_datetools2.patch the only nitpick i have is with the class level javadocs... *

In {@link RangeQuery}s, QueryParser tries to detect date values, e.g. date:[6/1/2005 TO 6/4/2005] * produces a range query that searches for "date" fields between 2005-06-01 and 2005-06-04. Note * that the format of the accepted input depends on {@link #setLocale(Locale) the locale}. * By default a date is formatted using the deprecated {@link DateField} for compatibility reasons. * To use the new {@link DateTools} to format dates, a {@link DateTools.Resolution} has to be set.

*

The date resolution that shall be used for RangeQueries can be set using {@link #setDateResolution(DateTools.Resolution) ...the word "format" is used to mean two very differnet things in this paragraph, we should clean that up so it's clera that Locale determines the DateFormat QP uses when trying to parse input in [a TO b] syntax, while either DateField or DateTools are used to create the "indexed" value queried against. > Support DateTools in QueryParser > -------------------------------- > > Key: LUCENE-732 > URL: http://issues.apache.org/jira/browse/LUCENE-732 > 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: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: java-dev-unsubscribe@lucene.apache.org For additional commands, e-mail: java-dev-help@lucene.apache.org