org.apache.solr.schema
Class DateField

java.lang.Object
  extended by org.apache.solr.schema.FieldType
      extended by org.apache.solr.schema.DateField

public class DateField
extends FieldType

FieldType that can represent any Date/Time with millisecond precisison.

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. Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z 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. http://www.w3.org/TR/xmlschema-2/#dateTime

"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."

This FieldType also supports incoming "Date Math" strings for computing values by adding/rounding internals of time relative "NOW", ie: "NOW+1YEAR", "NOW/DAY", etc.. -- see DateMathParser for more examples.

Version:
$Id: DateField.java 542679 2007-05-29 22:28:21Z ryan $
Author:
yonik
See Also:
XML schema part 2

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.solr.schema.FieldType
FieldType.DefaultAnalyzer
 
Field Summary
static java.util.TimeZone UTC
           
 
Fields inherited from class org.apache.solr.schema.FieldType
analyzer, args, falseProperties, log, queryAnalyzer, trueProperties, typeName
 
Constructor Summary
DateField()
           
 
Method Summary
 org.apache.lucene.search.SortField getSortField(SchemaField field, boolean reverse)
          Returns the SortField instance that should be used to sort fields of this type.
protected  java.text.DateFormat getThreadLocalDateFormat()
          Returns a formatter that can be use by the current thread if needed to convert Date objects to the Internal representation.
 ValueSource getValueSource(SchemaField field)
          called to get the default value source (normally, from the Lucene FieldCache.)
 java.lang.String indexedToReadable(java.lang.String indexedForm)
          :TODO: document this method
protected  void init(IndexSchema schema, java.util.Map<java.lang.String,java.lang.String> args)
          subclasses should initialize themselves with the args provided and remove valid arguments.
 java.lang.String toExternal(org.apache.lucene.document.Fieldable f)
          Convert the stored-field format to an external (string, human readable) value
 java.lang.String toInternal(java.util.Date val)
           
 java.lang.String toInternal(java.lang.String val)
          Convert an external value (from XML update command or from query string) into the internal format.
 void write(TextResponseWriter writer, java.lang.String name, org.apache.lucene.document.Fieldable f)
          calls back to TextResponseWriter to write the field value
 void write(XMLWriter xmlWriter, java.lang.String name, org.apache.lucene.document.Fieldable f)
          Renders the specified field as XML
 
Methods inherited from class org.apache.solr.schema.FieldType
createField, getAnalyzer, getFieldIndex, getFieldStore, getFieldTermVec, getQueryAnalyzer, getStringSort, getTypeName, isTokenized, 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

UTC

public static java.util.TimeZone UTC
Constructor Detail

DateField

public DateField()
Method Detail

init

protected void init(IndexSchema schema,
                    java.util.Map<java.lang.String,java.lang.String> args)
Description copied from class: FieldType
subclasses should initialize themselves with the args provided and remove valid arguments. leftover arguments will cause an exception. Common boolean properties have already been handled.

Overrides:
init in class FieldType

toInternal

public java.lang.String toInternal(java.lang.String val)
Description copied from class: FieldType
Convert an external value (from XML update command or from query string) into the internal format.

Overrides:
toInternal in class FieldType
See Also:
FieldType.toExternal(org.apache.lucene.document.Fieldable)

toInternal

public java.lang.String toInternal(java.util.Date val)

indexedToReadable

public java.lang.String indexedToReadable(java.lang.String indexedForm)
Description copied from class: FieldType
:TODO: document this method

Overrides:
indexedToReadable in class FieldType

toExternal

public java.lang.String toExternal(org.apache.lucene.document.Fieldable f)
Description copied from class: FieldType
Convert the stored-field format to an external (string, human readable) value

Overrides:
toExternal in class FieldType
See Also:
FieldType.toInternal(java.lang.String)

getSortField

public org.apache.lucene.search.SortField getSortField(SchemaField field,
                                                       boolean reverse)
Description copied from class: FieldType
Returns the SortField instance that should be used to sort fields of this type.

Specified by:
getSortField in class FieldType

getValueSource

public ValueSource getValueSource(SchemaField field)
Description copied from class: FieldType
called to get the default value source (normally, from the Lucene FieldCache.)

Overrides:
getValueSource in class FieldType

write

public void write(XMLWriter xmlWriter,
                  java.lang.String name,
                  org.apache.lucene.document.Fieldable f)
           throws java.io.IOException
Description copied from class: FieldType
Renders the specified field as XML

Specified by:
write in class FieldType
Throws:
java.io.IOException

write

public void write(TextResponseWriter writer,
                  java.lang.String name,
                  org.apache.lucene.document.Fieldable f)
           throws java.io.IOException
Description copied from class: FieldType
calls back to TextResponseWriter to write the field value

Specified by:
write in class FieldType
Throws:
java.io.IOException

getThreadLocalDateFormat

protected java.text.DateFormat getThreadLocalDateFormat()
Returns a formatter that can be use by the current thread if needed to convert Date objects to the Internal representation.



Copyright © 2006 - 2008 The Apache Software Foundation