From 57653c5490fcf2814125f99f6cc8b2315682f080 Mon Sep 17 00:00:00 2001 From: "Chris M. Hostetter" Date: Tue, 21 Nov 2006 01:55:05 +0000 Subject: [PATCH] SOLR-71: Date Math for DateField git-svn-id: https://svn.apache.org/repos/asf/incubator/solr/trunk@477465 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 5 +- example/exampledocs/solr.xml | 1 + example/solr/conf/schema.xml | 18 +- example/solr/conf/solrconfig.xml | 4 + .../org/apache/solr/schema/DateField.java | 61 +++- .../org/apache/solr/util/DateMathParser.java | 289 +++++++++++++++++ .../apache/solr/BasicFunctionalityTest.java | 38 ++- .../apache/solr/util/DateMathParserTest.java | 293 ++++++++++++++++++ 8 files changed, 702 insertions(+), 7 deletions(-) create mode 100644 src/java/org/apache/solr/util/DateMathParser.java create mode 100644 src/test/org/apache/solr/util/DateMathParserTest.java diff --git a/CHANGES.txt b/CHANGES.txt index 2056438cd4c..1231b0753d7 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -65,7 +65,10 @@ New Features 29. autoCommit can be specified every so many documents added (klaas, SOLR-65) 30. ${solr.home}/lib directory can now be used for specifying "plugin" jars (hossman, SOLR-68) - +31. Support for "Date Math" relative "NOW" when specifying values of a + DateField in a query -- or when adding a document. + (hossman, SOLR-71) + Changes in runtime behavior 1. classes reorganized into different packages, package names changed to Apache 2. force read of document stored fields in QuerySenderListener diff --git a/example/exampledocs/solr.xml b/example/exampledocs/solr.xml index 26e292ac450..fb8ff9f9721 100644 --- a/example/exampledocs/solr.xml +++ b/example/exampledocs/solr.xml @@ -32,6 +32,7 @@ 0 10 true + 2006-01-17T00:00:00.000Z diff --git a/example/solr/conf/schema.xml b/example/solr/conf/schema.xml index 7850130cee7..560179d67b4 100755 --- a/example/solr/conf/schema.xml +++ b/example/solr/conf/schema.xml @@ -83,11 +83,25 @@ + All other components are mandatory. + + Expressions can also be used to denote calculations which should be + performed relative "NOW" to determine the value, ie... + + NOW/HOUR + ... Round to the start of the current hour + NOW-1DAY + ... Exactly 1 day prior to now + NOW/DAY+6MONTHS+3DAYS + ... 6 months and 3 days in the future from the start of + the current day + + Consult the DateField javadocs for more information. + --> + incubationdate_dt:[* TO NOW/DAY-1MONTH]^2.2