|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.solr.schema.FieldType
org.apache.solr.schema.DateField
public class DateField
FieldType that can represent any Date/Time with millisecond precision.
Date Format for the XML, incoming and outgoing:
A date field shall be of the form 1995-12-31T23:59:59Z The trailing "Z" designates UTC time and is mandatory (See below for an explanation of UTC). Optional fractional seconds are allowed, as long as they do not end in a trailing 0 (but any precision beyond milliseconds will be ignored). All other parts are mandatory.
This format was derived to be standards compliant (ISO 8601) and is a more restricted form of the canonical representation of dateTime from XML schema part 2. Examples...
Note that DateField is lenient with regards to parsing fractional seconds that end in trailing zeros and will ensure that those values are indexed in the correct canonical format.
This FieldType also supports incoming "Date Math" strings for computing
values by adding/rounding internals of time relative either an explicit
datetime (in the format specified above) or the literal string "NOW",
ie: "NOW+1YEAR", "NOW/DAY", "1995-12-31T23:59:59.999Z+5MINUTES", etc...
-- see DateMathParser
for more examples.
Explanation of "UTC"...
"In 1970 the Coordinated Universal Time system was devised by an international advisory group of technical experts within the International Telecommunication Union (ITU). The ITU felt it was best to designate a single abbreviation for use in all languages in order to minimize confusion. Since unanimous agreement could not be achieved on using either the English word order, CUT, or the French word order, TUC, the acronym UTC was chosen as a compromise."
Nested Class Summary |
---|
Nested classes/interfaces inherited from class org.apache.solr.schema.FieldType |
---|
FieldType.DefaultAnalyzer |
Field Summary | |
---|---|
protected static Locale |
CANONICAL_LOCALE
Fixed Locale needed for parsing/formating Milliseconds in the canonical representation. |
protected static TimeZone |
CANONICAL_TZ
Fixed TimeZone (UTC) needed for parsing/formating Dates in the canonical representation. |
protected static Locale |
MATH_LOCALE
Locale for DateMath (Locale.US) |
protected static TimeZone |
MATH_TZ
TimeZone for DateMath (UTC) |
protected static String |
NOW
|
static TimeZone |
UTC
|
protected static char |
Z
|
Fields inherited from class org.apache.solr.schema.FieldType |
---|
analyzer, args, falseProperties, log, queryAnalyzer, trueProperties, typeName |
Constructor Summary | |
---|---|
DateField()
|
Method Summary | |
---|---|
protected String |
formatDate(Date d)
Thread safe method that can be used by subclasses to format a Date using the Internal representation. |
Query |
getRangeQuery(QParser parser,
SchemaField sf,
Date part1,
Date part2,
boolean minInclusive,
boolean maxInclusive)
DateField specific range query |
SortField |
getSortField(SchemaField field,
boolean reverse)
Returns the SortField instance that should be used to sort fields of this type. |
protected DateFormat |
getThreadLocalDateFormat()
Deprecated. - use formatDate(Date) instead |
ValueSource |
getValueSource(SchemaField field)
|
ValueSource |
getValueSource(SchemaField field,
QParser parser)
called to get the default value source (normally, from the Lucene FieldCache.) |
String |
indexedToReadable(String indexedForm)
Given an indexed term, return the human readable representation |
protected void |
init(IndexSchema schema,
Map<String,String> args)
subclasses should initialize themselves with the args provided and remove valid arguments. |
protected Date |
parseDate(String s)
Thread safe method that can be used by subclasses to parse a Date that is already in the internal representation |
Date |
parseDateLenient(String s,
SolrQueryRequest req)
Parse a date string in the standard format, or any supported by DateUtil.parseDate |
Date |
parseMath(Date now,
String val)
Parses a String which may be a date (in the standard format) followed by an optional math expression. |
Date |
parseMathLenient(Date now,
String val,
SolrQueryRequest req)
Parses a String which may be a date followed by an optional math expression. |
String |
toExternal(Date d)
Return the standard human readable form of the date |
String |
toExternal(Fieldable f)
Convert the stored-field format to an external (string, human readable) value |
String |
toInternal(Date val)
|
String |
toInternal(String val)
Convert an external value (from XML update command or from query string) into the internal format for both storing and indexing (which can be modified by any analyzers). |
Date |
toObject(Fieldable f)
Convert the stored-field format to an external object. |
Date |
toObject(String indexedForm)
|
void |
write(TextResponseWriter writer,
String name,
Fieldable f)
calls back to TextResponseWriter to write the field value |
void |
write(XMLWriter xmlWriter,
String name,
Fieldable f)
Renders the specified field as XML |
Methods inherited from class org.apache.solr.schema.FieldType |
---|
createField, getAnalyzer, getArg, getFieldIndex, getFieldStore, getFieldTermVec, getQueryAnalyzer, getRangeQuery, getStringSort, getTypeName, isMultiValued, isTokenized, multiValuedFieldCache, readableToIndexed, restrictProps, setAnalyzer, setQueryAnalyzer, storedToIndexed, storedToReadable, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static TimeZone UTC
protected static final TimeZone MATH_TZ
protected static final Locale MATH_LOCALE
protected static final TimeZone CANONICAL_TZ
protected static final Locale CANONICAL_LOCALE
protected static String NOW
protected static char Z
Constructor Detail |
---|
public DateField()
Method Detail |
---|
protected void init(IndexSchema schema, Map<String,String> args)
FieldType
init
in class FieldType
public String toInternal(String val)
FieldType
toInternal
in class FieldType
FieldType.toExternal(org.apache.lucene.document.Fieldable)
public Date parseMath(Date now, String val)
now
- an optional fixed date to use as "NOW" in the DateMathParserval
- the string to parsepublic String toInternal(Date val)
public String indexedToReadable(String indexedForm)
FieldType
indexedToReadable
in class FieldType
public String toExternal(Fieldable f)
FieldType
toExternal
in class FieldType
FieldType.toInternal(java.lang.String)
public Date toObject(String indexedForm) throws ParseException
ParseException
public Date toObject(Fieldable f)
FieldType
toObject
in class FieldType
FieldType.toInternal(java.lang.String)
public SortField getSortField(SchemaField field, boolean reverse)
FieldType
getSortField
in class FieldType
public ValueSource getValueSource(SchemaField field)
getValueSource
in class FieldType
public void write(XMLWriter xmlWriter, String name, Fieldable f) throws IOException
FieldType
write
in class FieldType
IOException
public void write(TextResponseWriter writer, String name, Fieldable f) throws IOException
FieldType
write
in class FieldType
IOException
protected DateFormat getThreadLocalDateFormat()
protected String formatDate(Date d)
public String toExternal(Date d)
protected Date parseDate(String s) throws ParseException
ParseException
public Date parseDateLenient(String s, SolrQueryRequest req) throws ParseException
ParseException
public Date parseMathLenient(Date now, String val, SolrQueryRequest req)
now
- an optional fixed date to use as "NOW" in the DateMathParserval
- the string to parsepublic ValueSource getValueSource(SchemaField field, QParser parser)
FieldType
getValueSource
in class FieldType
public Query getRangeQuery(QParser parser, SchemaField sf, Date part1, Date part2, boolean minInclusive, boolean maxInclusive)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |