Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16726: Adding Date Math expression units to docs (#1507)

Justin Sweeney9830bbbabcb3
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