Esri Geoportal Server
1.0

com.esri.gpt.catalog.lucene
Class DatastoreField

java.lang.Object
  extended by com.esri.gpt.catalog.lucene.DatastoreField
Direct Known Subclasses:
DoubleField, LongField, LowerCaseField, ReferenceField, TermsField, TimestampField

public class DatastoreField
extends Object

Represents a field that is held within the underlying data store.


Constructor Summary
protected DatastoreField(String name, Field.Store storageOption, Field.Index indexingOption, Field.TermVector termVectorOption)
          Constructs with fully supplied parameters.
 
Method Summary
protected  void appendForWrite(Document document, Object value)
          Appends the field to a document prior to writing the document to the index.
protected  Field.Index getIndexingOption()
          Gets the indexing option.
protected  String getName()
          Gets the field name.
protected  Field.Store getStorageOption()
          Gets the storage option.
protected  Field.TermVector getTermVectorOption()
          Gets the term vector option.
protected  Fieldable makeFieldable(Object value)
          Makes the fieldable to index.
protected  Query makeRangeQuery(String literalLowerValue, String literalUpperValue, boolean lowerBoundaryIsInclusive, boolean upperBoundaryIsInclusive)
          Makes a range query.
protected  String makeValueToQuery(String value, boolean isLowerBoundary, boolean isUpperBoundary)
          Makes the value to query.
protected  Object makeValueToReturn(String storedValue)
          Makes the value to return in the query result.
protected  void setIndexingOption(Field.Index indexingOption)
          Sets the indexing option.
protected  void setName(String name)
          Sets the field name.
protected  void setStorageOption(Field.Store storageOption)
          Sets the storage option.
protected  void setTermVectorOption(Field.TermVector termVectorOption)
          Sets the term vector option.
protected  int sortFieldType()
          Returns the sort field type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatastoreField

protected DatastoreField(String name,
                         Field.Store storageOption,
                         Field.Index indexingOption,
                         Field.TermVector termVectorOption)
Constructs with fully supplied parameters.

Parameters:
name - the field name
storageOption - the storage option
indexingOption - the indexing option
termVectorOption - the term vector option
Method Detail

getIndexingOption

protected Field.Index getIndexingOption()
Gets the indexing option.

Returns:
the indexing option

setIndexingOption

protected void setIndexingOption(Field.Index indexingOption)
Sets the indexing option.

Parameters:
indexingOption - the indexing option

getName

protected String getName()
Gets the field name.

Returns:
the field name

setName

protected void setName(String name)
Sets the field name.
The name will be trimmed, a null name is treated as an empty string.

Parameters:
name - the field name

getStorageOption

protected Field.Store getStorageOption()
Gets the storage option.

Returns:
the storage option

setStorageOption

protected void setStorageOption(Field.Store storageOption)
Sets the storage option.

Parameters:
storageOption - the storage option

getTermVectorOption

protected Field.TermVector getTermVectorOption()
Gets the term vector option.

Returns:
the term vector option

setTermVectorOption

protected void setTermVectorOption(Field.TermVector termVectorOption)
Sets the term vector option.

Parameters:
termVectorOption - the term vector option

appendForWrite

protected void appendForWrite(Document document,
                              Object value)
Appends the field to a document prior to writing the document to the index.

The field will not be appended if it's name or value is empty.

Parameters:
document - the Lucene document
value - the input value to write

makeFieldable

protected Fieldable makeFieldable(Object value)
Makes the fieldable to index.

Sub-classes should override this method if converted values need to be written for subsequent search (ex. Doubles, Longs, Timestamps ...).

The default behavior is to return the supplied value.
Null or empty values will not be stored.

Parameters:
value - the value
Returns:
the fieldable

makeRangeQuery

protected Query makeRangeQuery(String literalLowerValue,
                               String literalUpperValue,
                               boolean lowerBoundaryIsInclusive,
                               boolean upperBoundaryIsInclusive)
                        throws DiscoveryException
Makes a range query.

Sub-classes should override this method if values need to be converted for a search (ex. Doubles, Longs, Timestamps, ...).

The default behavior is to return a new TermRangeQuery.

Parameters:
literalLowerValue - the literal lower boundary value
literalUpperValue - the literal upper boundary value
lowerBoundaryIsInclusive - (>= versus >)
upperBoundaryIsInclusive - (<= versus <)
Throws:
DiscoveryException - if the supplied value cannot be converted

makeValueToQuery

protected String makeValueToQuery(String value,
                                  boolean isLowerBoundary,
                                  boolean isUpperBoundary)
                           throws DiscoveryException
Makes the value to query.

Sub-classes should override this method if values need to be converted for a search (ex. Doubles, Longs, Timestamps, ...).

The default behavior is to return the supplied value.

Parameters:
value - to input query value
isLowerBoundary - true if this is a lower boundary of a range query
isUpperBoundary - true if this is a upper boundary of a range query
Returns:
the value to query
Throws:
DiscoveryException - if the supplied value cannot be converted

makeValueToReturn

protected Object makeValueToReturn(String storedValue)
Makes the value to return in the query result.

The value should be converted if required (example: from a double stored as an indexable string within the document back to it's original form).

The default behavior is to return the supplied value of the field. Sub-classes should override this method if the value needs to be converted back to a Double, Long, Timestamp, ...

Parameters:
storedValue - the value stored within the Lucene document
Returns:
the associated object value

sortFieldType

protected int sortFieldType()
Returns the sort field type.

Sub-classes should override this method if values are numeric (ex. Doubles, Longs, Timestamps, ...).

Returns:
the sort field type (by default SortField.STRING)

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.