TrieDateField
instead@Deprecated public class DateField extends PrimitiveFieldType implements DateValueFieldType
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.
NOTE: Allthough it is possible to configure a DateField
instance with a default value of "NOW
" to compute a timestamp
of when the document was indexed, this is not advisable when using SolrCloud
since each replica of the document may compute a slightly different value.
TimestampUpdateProcessorFactory
is recomended instead.
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."
FieldType.DefaultAnalyzer
Modifier and Type | Field and Description |
---|---|
protected static Locale |
CANONICAL_LOCALE
Deprecated.
Fixed Locale needed for parsing/formating Milliseconds in the
canonical representation.
|
protected static TimeZone |
CANONICAL_TZ
Deprecated.
Fixed TimeZone (UTC) needed for parsing/formating Dates in the
canonical representation.
|
protected static Locale |
MATH_LOCALE
Deprecated.
use DateMathParser.DEFAULT_MATH_LOCALE
|
protected static TimeZone |
MATH_TZ
Deprecated.
use DateMathParser.DEFAULT_MATH_TZ
|
protected static String |
NOW
Deprecated.
|
static TimeZone |
UTC
Deprecated.
|
protected static char |
Z
Deprecated.
|
ANALYZER, args, CHAR_FILTER, CHAR_FILTERS, CLASS_NAME, docValuesFormat, falseProperties, FILTER, FILTERS, INDEX, INDEX_ANALYZER, log, MULTI_TERM, MULTI_TERM_ANALYZER, POLY_FIELD_SEPARATOR, postingsFormat, properties, QUERY, QUERY_ANALYZER, similarity, SIMILARITY, similarityFactory, TOKENIZER, trueProperties, TYPE, TYPE_NAME, typeName
BINARY, DOC_VALUES, INDEXED, MULTIVALUED, OMIT_NORMS, OMIT_POSITIONS, OMIT_TF_POSITIONS, REQUIRED, SORT_MISSING_FIRST, SORT_MISSING_LAST, STORE_OFFSETS, STORE_TERMOFFSETS, STORE_TERMPOSITIONS, STORE_TERMVECTORS, STORED, TOKENIZED
Constructor and Description |
---|
DateField()
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
IndexableField |
createField(SchemaField field,
Object value,
float boost)
Deprecated.
Used for adding a document when a field needs to be created from a
type and a string.
|
protected String |
formatDate(Date d)
Deprecated.
Thread safe method that can be used by subclasses to format a Date
using the Internal representation.
|
static String |
formatExternal(Date d)
Deprecated.
Return the standard human readable form of the date
|
Query |
getRangeQuery(QParser parser,
SchemaField sf,
Date part1,
Date part2,
boolean minInclusive,
boolean maxInclusive)
Deprecated.
DateField specific range query
|
SortField |
getSortField(SchemaField field,
boolean reverse)
Deprecated.
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,
QParser parser)
Deprecated.
called to get the default value source (normally, from the
Lucene FieldCache.)
|
CharsRef |
indexedToReadable(BytesRef input,
CharsRef charsRef)
Deprecated.
Given an indexed term, append the human readable representation
|
String |
indexedToReadable(String indexedForm)
Deprecated.
Given an indexed term, return the human readable representation
|
Object |
marshalSortValue(Object value)
Deprecated.
Convert a value used by the FieldComparator for this FieldType's SortField
into a marshalable value for distributed sorting.
|
static Date |
parseDate(String s)
Deprecated.
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)
Deprecated.
Parse a date string in the standard format, or any supported by DateUtil.parseDate
|
Date |
parseMath(Date now,
String val)
Deprecated.
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)
Deprecated.
Parses a String which may be a date
followed by an optional math expression.
|
String |
toExternal(Date d)
Deprecated.
|
String |
toExternal(IndexableField f)
Deprecated.
Convert the stored-field format to an external (string, human readable)
value
|
String |
toInternal(Date val)
Deprecated.
|
String |
toInternal(String val)
Deprecated.
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(IndexableField f)
Deprecated.
Convert the stored-field format to an external object.
|
Date |
toObject(String indexedForm)
Deprecated.
|
Object |
unmarshalSortValue(Object value)
Deprecated.
Convert a value marshaled via
FieldType.marshalSortValue(java.lang.Object) back
into a value usable by the FieldComparator for this FieldType's SortField |
void |
write(TextResponseWriter writer,
String name,
IndexableField f)
Deprecated.
calls back to TextResponseWriter to write the field value
|
init
checkSchemaField, createField, createFields, getAnalyzer, getAnalyzerProperties, getClassArg, getDocValuesFormat, getFieldQuery, getIndexAnalyzer, getIndexOptions, getNamedPropertyValues, getNonFieldPropertyArgs, getNumericType, getPostingsFormat, getPrefixQuery, getQueryAnalyzer, getRangeQuery, getRewriteMethod, getSimilarity, getSimilarityFactory, getStringSort, getTypeName, hasProperty, isExplicitAnalyzer, isExplicitQueryAnalyzer, isMultiValued, isPolyField, isTokenized, marshalBase64SortValue, marshalStringSortValue, multiValuedFieldCache, readableToIndexed, readableToIndexed, restrictProps, setAnalyzer, setArgs, setIndexAnalyzer, setIsExplicitAnalyzer, setIsExplicitQueryAnalyzer, setQueryAnalyzer, setSimilarity, storedToIndexed, storedToReadable, supportsAnalyzers, toObject, toString, unmarshalBase64SortValue, unmarshalStringSortValue
public static TimeZone UTC
protected static final TimeZone MATH_TZ
DateMathParser.DEFAULT_MATH_TZ
protected static final Locale MATH_LOCALE
DateMathParser.DEFAULT_MATH_LOCALE
protected static final TimeZone CANONICAL_TZ
protected static final Locale CANONICAL_LOCALE
protected static String NOW
protected static char Z
public String toInternal(String val)
FieldType
toInternal
in class FieldType
FieldType.toExternal(org.apache.lucene.index.IndexableField)
public Date parseMath(Date now, String val)
now
- an optional fixed date to use as "NOW" in the DateMathParserval
- the string to parsepublic IndexableField createField(SchemaField field, Object value, float boost)
FieldType
By default, the indexed value is the same as the stored value (taken from toInternal()). Having a different representation for external, internal, and indexed would present quite a few problems given the current Lucene architecture. An analyzer for adding docs would need to translate internal->indexed while an analyzer for querying would need to translate external->indexed.
The only other alternative to having internal==indexed would be to have internal==external. In this case, toInternal should convert to the indexed representation, toExternal() should do nothing, and createField() should *not* call toInternal, but use the external value and set tokenized=true to get Lucene to convert to the internal(indexed) form.
:TODO: clean up and clarify this explanation.createField
in class FieldType
FieldType.toInternal(java.lang.String)
public String indexedToReadable(String indexedForm)
FieldType
indexedToReadable
in class FieldType
public CharsRef indexedToReadable(BytesRef input, CharsRef charsRef)
FieldType
indexedToReadable
in class FieldType
public String toExternal(IndexableField f)
FieldType
toExternal
in class FieldType
FieldType.toInternal(java.lang.String)
public Date toObject(String indexedForm) throws ParseException
ParseException
public Date toObject(IndexableField f)
FieldType
toObject
in class FieldType
FieldType.toInternal(java.lang.String)
public SortField getSortField(SchemaField field, boolean reverse)
FieldType
getSortField
in class FieldType
SchemaField.checkSortability()
public Object marshalSortValue(Object value)
FieldType
marshalSortValue
in class FieldType
public Object unmarshalSortValue(Object value)
FieldType
FieldType.marshalSortValue(java.lang.Object)
back
into a value usable by the FieldComparator for this FieldType's SortFieldunmarshalSortValue
in class FieldType
public void write(TextResponseWriter writer, String name, IndexableField f) throws IOException
FieldType
write
in class FieldType
IOException
@Deprecated protected DateFormat getThreadLocalDateFormat()
protected String formatDate(Date d)
public static String formatExternal(Date d)
public String toExternal(Date d)
formatExternal(java.util.Date)
public static 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)
Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.