lux.index.field
Class FieldDefinition

java.lang.Object
  extended by lux.index.field.FieldDefinition
Direct Known Subclasses:
AttributeQNameField, AttributeTextField, DocumentField, ElementQNameField, ElementTextField, PathField, PathOccurrenceField, PathValueField, QNameValueField, TinyBinaryField, URIField, XmlTextField, XPathField

public abstract class FieldDefinition
extends Object

represents a field in the index corresponding to some XML content. An XmlField has a name, which may be configured, but must remain the same for all uses of a single index. XmlField provides methods for retrieving Lucene field configuration, and for retrieving values from the XmlIndexer to be passed to Lucene. see IndexConfiguration for a list of current built-in fields.


Nested Class Summary
static class FieldDefinition.Type
          Represents the type of data fed to the index for a given field.
 
Constructor Summary
FieldDefinition(String name, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.document.Field.Store isStored, FieldDefinition.Type type)
          construct an non-renameable field
FieldDefinition(String name, org.apache.lucene.analysis.Analyzer analyzer, org.apache.lucene.document.Field.Store isStored, FieldDefinition.Type type, boolean renameable)
          Represents a Solr/Lucene field
 
Method Summary
 org.apache.lucene.analysis.Analyzer getAnalyzer()
           
 String getDefaultName()
          Note that field name uniqueness is not enforced by the API, but if two fields with different options share the same name, unpredictable behavior will ensue! This is an historical quirk of Lucene, which allows indexing a field in different ways at different times without enforcing a consistent schema.
 Iterable<? extends org.apache.lucene.index.IndexableField> getFieldValues(XmlIndexer indexer)
          Wraps the values as Field, which includes the values and the Lucene indexing options.
 int getSolrFieldProperties()
          Attempts to guess the Solr field properties (see FieldProperties) based on the available information.
 FieldDefinition.Type getType()
           
 Iterable<?> getValues(XmlIndexer indexer)
          The Solr XmlUpdateProcessor calls this.
 boolean isRenameable()
           
 boolean isSingleValued()
           
 org.apache.lucene.document.Field.Store isStored()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FieldDefinition

public FieldDefinition(String name,
                       org.apache.lucene.analysis.Analyzer analyzer,
                       org.apache.lucene.document.Field.Store isStored,
                       FieldDefinition.Type type,
                       boolean renameable)
Represents a Solr/Lucene field

Parameters:
name - the name of the field
analyzer - the analyzer associated with the field. This will be used to analyze string field values, and to analyze queries. If the field values are not strings (eg if they are a TokenStream), the analyzer is used only for queries.
isStored - whether the field values are to be stored
type - the type of the field values: STRING, TOKENS, INT.
renameable - whether the field is allowed to be renamed

FieldDefinition

public FieldDefinition(String name,
                       org.apache.lucene.analysis.Analyzer analyzer,
                       org.apache.lucene.document.Field.Store isStored,
                       FieldDefinition.Type type)
construct an non-renameable field

Parameters:
name - the name of the field
analyzer - the analyzer associated with the field. This will be used to analyze string field values, and to analyze queries. If the field values are not strings (eg if they are a TokenStream), the analyzer is used only for queries.
isStored - whether the field values are to be stored
type - the type of the field values: STRING, TOKENS, INT.
Method Detail

isRenameable

public boolean isRenameable()

getFieldValues

public Iterable<? extends org.apache.lucene.index.IndexableField> getFieldValues(XmlIndexer indexer)
Wraps the values as Field, which includes the values and the Lucene indexing options. Subclasses must implement getValues() or override this method

Parameters:
indexer - the indexer that holds the field values
Returns:
the accumulated values of the field, as IndexableFields

getValues

public Iterable<?> getValues(XmlIndexer indexer)
The Solr XmlUpdateProcessor calls this. If it returns null, the caller should use the values from getFieldValues() instead.

Parameters:
indexer - the indexer that holds the field values
Returns:
the accumulated values of the field, as primitive objects (String or Integer). If

getDefaultName

public String getDefaultName()
Note that field name uniqueness is not enforced by the API, but if two fields with different options share the same name, unpredictable behavior will ensue! This is an historical quirk of Lucene, which allows indexing a field in different ways at different times without enforcing a consistent schema.

Returns:
the unique name of the field, used in queries and when adding values during indexing

getType

public FieldDefinition.Type getType()
Returns:
The type of data stored in the field.

getAnalyzer

public org.apache.lucene.analysis.Analyzer getAnalyzer()

isStored

public org.apache.lucene.document.Field.Store isStored()

isSingleValued

public boolean isSingleValued()

getSolrFieldProperties

public int getSolrFieldProperties()
Attempts to guess the Solr field properties (see FieldProperties) based on the available information. Subclasses may need to override to get the correct behavior. Norms are omitted from all fields; all fields except uri are assumed to be multi-valued.

Returns:
the Solr field properties to use when creating a Solr Schema field dynamically

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2013. All Rights Reserved.