You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@solr.apache.org by js...@apache.org on 2023/03/30 17:48:19 UTC

[solr] branch main updated: SOLR-16726: Adding Date Math expression units to docs (#1507)

This is an automated email from the ASF dual-hosted git repository.

jsweeney pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new 9830bbbabcb SOLR-16726: Adding Date Math expression units to docs (#1507)
9830bbbabcb is described below

commit 9830bbbabcb30570e21e7648331b4ac8fa59d6a9
Author: Justin Sweeney <ju...@fullstory.com>
AuthorDate: Thu Mar 30 13:48:11 2023 -0400

    SOLR-16726: Adding Date Math expression units to docs (#1507)
    
    * Adding Date Math expression units to docs
---
 .../java/org/apache/solr/util/DateMathParser.java  |  3 +++
 .../indexing-guide/pages/date-formatting-math.adoc | 25 ++++++++++++++++++++++
 2 files changed, 28 insertions(+)

diff --git a/solr/core/src/java/org/apache/solr/util/DateMathParser.java b/solr/core/src/java/org/apache/solr/util/DateMathParser.java
index 89a1a1516b5..eef17572162 100644
--- a/solr/core/src/java/org/apache/solr/util/DateMathParser.java
+++ b/solr/core/src/java/org/apache/solr/util/DateMathParser.java
@@ -134,6 +134,9 @@ public class DateMathParser {
 
     // NOTE: Maybe eventually support NANOS
 
+    // NOTE: Any changes here should also make sure to update the list of options in the ref docs:
+    // https://solr.apache.org/guide/solr/latest/indexing-guide/date-formatting-math.html#date-math-syntax.
+
     return Map.ofEntries(
         Map.entry("YEAR", ChronoUnit.YEARS),
         Map.entry("YEARS", ChronoUnit.YEARS),
diff --git a/solr/solr-ref-guide/modules/indexing-guide/pages/date-formatting-math.adoc b/solr/solr-ref-guide/modules/indexing-guide/pages/date-formatting-math.adoc
index fd2bffe6a91..8da05250ad9 100644
--- a/solr/solr-ref-guide/modules/indexing-guide/pages/date-formatting-math.adoc
+++ b/solr/solr-ref-guide/modules/indexing-guide/pages/date-formatting-math.adoc
@@ -111,6 +111,31 @@ Note that while date math is most commonly used relative to `NOW` it can be appl
 
 `1972-05-20T17:33:18.772Z+6MONTHS+3DAYS/DAY`
 
+==== Date Math Unit Options ====
+The following units are valid for use in date math expressions. The first column is the value used in date math expressions in Solr. The second column is the chronological unit to which it maps, as multiple aliases exist for given units of time.
+
+|===
+|Date Math Expression Unit | Chronological Unit
+
+|YEAR | Years
+|YEARS | Years
+|MONTH | Months
+|MONTHS | Months
+|DAY | Days
+|DAYS | Days
+|DATE | Days
+|HOUR | Hours
+|HOURS | Hours
+|MINUTE | Minutes
+|MINUTES | Minutes
+|SECOND | Seconds
+|SECONDS | Seconds
+|MILLI | Milliseconds
+|MILLIS | Milliseconds
+|MILLISECOND | Milliseconds
+|MILLISECONDS | Milliseconds
+|===
+
 === Request Parameters That Affect Date Math
 
 ==== NOW