|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.solr.schema.FieldProperties org.apache.solr.schema.FieldType
public abstract class FieldType
Base class for all field types used by an index schema.
Nested Class Summary | |
---|---|
protected class |
FieldType.DefaultAnalyzer
Default analyzer for types that only produce 1 verbatim token... |
Field Summary | |
---|---|
protected Analyzer |
analyzer
Analyzer set by schema for text types to use when indexing fields of this type, subclasses can set analyzer themselves or override getAnalyzer() |
protected Map<String,String> |
args
additional arguments specified in the field type declaration |
protected String |
docValuesFormat
The docvalues format used for this field type |
protected int |
falseProperties
properties explicitly set to false |
static org.slf4j.Logger |
log
|
static String |
POLY_FIELD_SEPARATOR
The default poly field separator. |
protected String |
postingsFormat
The postings format used for this field type |
protected int |
properties
|
protected Analyzer |
queryAnalyzer
Analyzer set by schema for text types to use when searching fields of this type, subclasses can set analyzer themselves or override getAnalyzer() |
protected Similarity |
similarity
|
protected SimilarityFactory |
similarityFactory
|
protected int |
trueProperties
properties explicitly set to true |
protected String |
typeName
The name of the type (not the name of the field) |
Fields inherited from class org.apache.solr.schema.FieldProperties |
---|
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 Summary | |
---|---|
FieldType()
|
Method Summary | |
---|---|
void |
checkSchemaField(SchemaField field)
Check's SchemaField instances constructed
using this field type to ensure that they are valid. |
IndexableField |
createField(SchemaField field,
Object value,
float boost)
Used for adding a document when a field needs to be created from a type and a string. |
protected IndexableField |
createField(String name,
String val,
FieldType type,
float boost)
Create the field from native Lucene parts. |
List<IndexableField> |
createFields(SchemaField field,
Object value,
float boost)
Given a SchemaField , create one or more IndexableField instances |
Analyzer |
getAnalyzer()
Returns the Analyzer to be used when indexing fields of this type. |
protected static SimpleOrderedMap<Object> |
getAnalyzerProperties(Analyzer analyzer)
Returns a description of the given analyzer, by either reporting the Analyzer name if it's not a TokenizerChain, or if it is, querying each analysis factory for its name and args. |
String |
getDocValuesFormat()
|
Query |
getFieldQuery(QParser parser,
SchemaField field,
String externalVal)
Returns a Query instance for doing searches against a field. |
protected FieldInfo.IndexOptions |
getIndexOptions(SchemaField field,
String internalVal)
|
SimpleOrderedMap<Object> |
getNamedPropertyValues(boolean showDefaults)
Get a map of property name -> value for this field type. |
protected Map<String,String> |
getNonFieldPropertyArgs()
Returns args to this field type that aren't standard field properties |
FieldType.NumericType |
getNumericType()
Return the numeric type of this field, or null if this field is not a numeric field. |
String |
getPostingsFormat()
|
Analyzer |
getQueryAnalyzer()
Returns the Analyzer to be used when searching fields of this type. |
Query |
getRangeQuery(QParser parser,
SchemaField field,
String part1,
String part2,
boolean minInclusive,
boolean maxInclusive)
Returns a Query instance for doing range searches on this field type. |
MultiTermQuery.RewriteMethod |
getRewriteMethod(QParser parser,
SchemaField field)
Expert: Returns the rewrite method for multiterm queries such as wildcards. |
Similarity |
getSimilarity()
Gets the Similarity used when scoring fields of this type |
SimilarityFactory |
getSimilarityFactory()
Gets the factory for the Similarity used when scoring fields of this type |
protected SimpleOrderedMap<Object> |
getSimilarityProperties()
Returns a description of this field's similarity, if any |
abstract SortField |
getSortField(SchemaField field,
boolean top)
Returns the SortField instance that should be used to sort fields of this type. |
protected SortField |
getStringSort(SchemaField field,
boolean reverse)
Utility usable by subclasses when they want to get basic String sorting using common checks. |
String |
getTypeName()
The Name of this FieldType as specified in the schema file |
ValueSource |
getValueSource(SchemaField field,
QParser parser)
called to get the default value source (normally, from the Lucene FieldCache.) |
protected boolean |
hasProperty(int p)
Check if a property is set |
CharsRef |
indexedToReadable(BytesRef input,
CharsRef output)
Given an indexed term, append the human readable representation |
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. |
boolean |
isExplicitAnalyzer()
|
boolean |
isExplicitQueryAnalyzer()
|
boolean |
isMultiValued()
Returns true if fields can have multiple values |
boolean |
isPolyField()
A "polyField" is a FieldType that can produce more than one IndexableField instance for a single value, via the createFields(org.apache.solr.schema.SchemaField, Object, float) method. |
boolean |
isTokenized()
Returns true if fields of this type should be tokenized |
boolean |
multiValuedFieldCache()
Returns true if a single field value of this type has multiple logical values for the purposes of faceting, sorting, etc. |
void |
readableToIndexed(CharSequence val,
BytesRef result)
Given the readable value, return the term value that will match it. |
String |
readableToIndexed(String val)
Given the readable value, return the term value that will match it. |
protected void |
restrictProps(int props)
:TODO: document this method |
void |
setAnalyzer(Analyzer analyzer)
Sets the Analyzer to be used when indexing fields of this type. |
protected void |
setArgs(IndexSchema schema,
Map<String,String> args)
|
void |
setIsExplicitAnalyzer(boolean explicitAnalyzer)
|
void |
setIsExplicitQueryAnalyzer(boolean isExplicitQueryAnalyzer)
|
void |
setQueryAnalyzer(Analyzer analyzer)
Sets the Analyzer to be used when querying fields of this type. |
void |
setSimilarity(SimilarityFactory similarityFactory)
Sets the Similarity used when scoring fields of this type |
String |
storedToIndexed(IndexableField f)
Given the stored field, return the indexed form |
String |
storedToReadable(IndexableField f)
Given the stored field, return the human readable representation |
String |
toExternal(IndexableField f)
Convert the stored-field format to an external (string, human readable) value |
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). |
Object |
toObject(IndexableField f)
Convert the stored-field format to an external object. |
Object |
toObject(SchemaField sf,
BytesRef term)
|
String |
toString()
|
abstract void |
write(TextResponseWriter writer,
String name,
IndexableField f)
calls back to TextResponseWriter to write the field value |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final org.slf4j.Logger log
public static final String POLY_FIELD_SEPARATOR
createFields(SchemaField, Object, float)
,
isPolyField()
,
Constant Field Valuesprotected String typeName
protected Map<String,String> args
protected int trueProperties
protected int falseProperties
protected int properties
protected Analyzer analyzer
getAnalyzer()
,
setAnalyzer(org.apache.lucene.analysis.Analyzer)
protected Analyzer queryAnalyzer
getQueryAnalyzer()
,
setQueryAnalyzer(org.apache.lucene.analysis.Analyzer)
protected SimilarityFactory similarityFactory
protected Similarity similarity
protected String postingsFormat
protected String docValuesFormat
Constructor Detail |
---|
public FieldType()
Method Detail |
---|
public boolean isTokenized()
public boolean isMultiValued()
protected boolean hasProperty(int p)
public boolean isPolyField()
createFields(org.apache.solr.schema.SchemaField, Object, float)
method. This is useful
when hiding the implementation details of a field from the Solr end user. For instance, a spatial point may be represented by multiple different fields.
createFields(org.apache.solr.schema.SchemaField, Object, float)
method may return more than one fieldpublic boolean multiValuedFieldCache()
protected void init(IndexSchema schema, Map<String,String> args)
protected void setArgs(IndexSchema schema, Map<String,String> args)
protected void restrictProps(int props)
public String getTypeName()
public String toString()
toString
in class Object
public IndexableField createField(SchemaField field, Object value, float boost)
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.
toInternal(java.lang.String)
protected IndexableField createField(String name, String val, FieldType type, float boost)
name
- The name of the fieldval
- The _internal_ value to indextype
- FieldType
boost
- The boost value
IndexableField
.public List<IndexableField> createFields(SchemaField field, Object value, float boost)
SchemaField
, create one or more IndexableField
instances
field
- the SchemaField
value
- The value to add to the fieldboost
- The boost to apply
IndexableField
createField(SchemaField, Object, float)
,
isPolyField()
protected FieldInfo.IndexOptions getIndexOptions(SchemaField field, String internalVal)
public String toInternal(String val)
toExternal(org.apache.lucene.index.IndexableField)
public String toExternal(IndexableField f)
toInternal(java.lang.String)
public Object toObject(IndexableField f)
toInternal(java.lang.String)
public Object toObject(SchemaField sf, BytesRef term)
public String indexedToReadable(String indexedForm)
public CharsRef indexedToReadable(BytesRef input, CharsRef output)
public String storedToReadable(IndexableField f)
public String storedToIndexed(IndexableField f)
public String readableToIndexed(String val)
public void readableToIndexed(CharSequence val, BytesRef result)
public void setIsExplicitQueryAnalyzer(boolean isExplicitQueryAnalyzer)
public boolean isExplicitQueryAnalyzer()
public void setIsExplicitAnalyzer(boolean explicitAnalyzer)
public boolean isExplicitAnalyzer()
public Analyzer getAnalyzer()
This method may be called many times, at any time.
getQueryAnalyzer()
public Analyzer getQueryAnalyzer()
This method may be called many times, at any time.
getAnalyzer()
public void setAnalyzer(Analyzer analyzer)
The default implementation throws a SolrException. Subclasses that override this method need to ensure the behavior of the analyzer is consistent with the implementation of toInternal.
toInternal(java.lang.String)
,
setQueryAnalyzer(org.apache.lucene.analysis.Analyzer)
,
getAnalyzer()
public void setQueryAnalyzer(Analyzer analyzer)
The default implementation throws a SolrException. Subclasses that override this method need to ensure the behavior of the analyzer is consistent with the implementation of toInternal.
toInternal(java.lang.String)
,
setAnalyzer(org.apache.lucene.analysis.Analyzer)
,
getQueryAnalyzer()
public Similarity getSimilarity()
The default implementation returns null, which means this type has no custom similarity associated with it.
public SimilarityFactory getSimilarityFactory()
The default implementation returns null, which means this type has no custom similarity factory associated with it.
public FieldType.NumericType getNumericType()
public void setSimilarity(SimilarityFactory similarityFactory)
public String getPostingsFormat()
public final String getDocValuesFormat()
public abstract void write(TextResponseWriter writer, String name, IndexableField f) throws IOException
IOException
public abstract SortField getSortField(SchemaField field, boolean top)
SchemaField.checkSortability()
protected SortField getStringSort(SchemaField field, boolean reverse)
SchemaField.checkSortability()
public ValueSource getValueSource(SchemaField field, QParser parser)
public Query getRangeQuery(QParser parser, SchemaField field, String part1, String part2, boolean minInclusive, boolean maxInclusive)
SolrQueryParser
currently passes part1 and part2 as null if they are '*' respectively. minInclusive and maxInclusive are both true
currently by SolrQueryParser but that may change in the future. Also, other QueryParser implementations may have
different semantics.
Sub-classes should override this method to provide their own range query implementation. They should strive to
handle nulls in part1 and/or part2 as well as unequal minInclusive and maxInclusive parameters gracefully.
field
- the schema fieldpart1
- the lower boundary of the range, nulls are allowed.part2
- the upper boundary of the range, nulls are allowedminInclusive
- whether the minimum of the range is inclusive or notmaxInclusive
- whether the maximum of the range is inclusive or not
public Query getFieldQuery(QParser parser, SchemaField field, String externalVal)
parser
- The QParser
calling the methodfield
- The SchemaField
of the field to searchexternalVal
- The String representation of the value to search
Query
instance. This implementation returns a TermQuery
but overriding queries may notpublic MultiTermQuery.RewriteMethod getRewriteMethod(QParser parser, SchemaField field)
parser
- The QParser
calling the methodfield
- The SchemaField
of the field to search
public void checkSchemaField(SchemaField field)
SchemaField
instances constructed
using this field type to ensure that they are valid.
This method is called by the SchemaField
constructor to
check that it's initialization does not violate any fundemental
requirements of the FieldType
. The default implementation
does nothing, but subclasses may chose to throw a SolrException
if invariants are violated by the SchemaField.
public SimpleOrderedMap<Object> getNamedPropertyValues(boolean showDefaults)
showDefaults
- if true, include default properties.protected Map<String,String> getNonFieldPropertyArgs()
protected static SimpleOrderedMap<Object> getAnalyzerProperties(Analyzer analyzer)
protected SimpleOrderedMap<Object> getSimilarityProperties()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |