public class CurrencyField extends FieldType implements SchemaAware, ResourceLoaderAware
FieldType.DefaultAnalyzer, FieldType.MultiValueSelector| Modifier and Type | Field and Description | 
|---|---|
| protected static String | DEFAULT_DEFAULT_CURRENCY | 
| protected static String | DEFAULT_PRECISION_STEP | 
| protected static String | DEFAULT_RATE_PROVIDER_CLASS | 
| protected static String | FIELD_SUFFIX_AMOUNT_RAW | 
| protected static String | FIELD_SUFFIX_CURRENCY | 
| protected FieldType | fieldTypeAmountRaw | 
| protected FieldType | fieldTypeCurrency | 
| protected static String | PARAM_DEFAULT_CURRENCY | 
| protected static Object | PARAM_PRECISION_STEP | 
| protected static String | PARAM_RATE_PROVIDER_CLASS | 
ANALYZER, args, AUTO_GENERATE_PHRASE_QUERIES, CHAR_FILTER, CHAR_FILTERS, CLASS_NAME, docValuesFormat, ENABLE_GRAPH_QUERIES, falseProperties, FILTER, FILTERS, INDEX, INDEX_ANALYZER, MULTI_TERM, MULTI_TERM_ANALYZER, POLY_FIELD_SEPARATOR, postingsFormat, properties, QUERY, QUERY_ANALYZER, similarity, SIMILARITY, similarityFactory, TOKENIZER, trueProperties, TYPE, TYPE_NAME, typeNameBINARY, DOC_VALUES, INDEXED, LARGE_FIELD, MULTIVALUED, OMIT_NORMS, OMIT_POSITIONS, OMIT_TF_POSITIONS, REQUIRED, SORT_MISSING_FIRST, SORT_MISSING_LAST, STORE_OFFSETS, STORE_TERMOFFSETS, STORE_TERMPAYLOADS, STORE_TERMPOSITIONS, STORE_TERMVECTORS, STORED, TOKENIZED, USE_DOCVALUES_AS_STORED| Constructor and Description | 
|---|
| CurrencyField() | 
| Modifier and Type | Method and Description | 
|---|---|
| void | checkSchemaField(SchemaField field)Check's  SchemaFieldinstances constructed 
 using this field type to ensure that they are valid. | 
| List<IndexableField> | createFields(SchemaField field,
            Object externalVal,
            float boost)Given a  SchemaField, create one or moreIndexableFieldinstances | 
| ValueSource | getConvertedValueSource(String targetCurrencyCode,
                       org.apache.solr.schema.CurrencyField.RawCurrencyValueSource source)
 Returns a ValueSource over this field in which the numeric value for 
 each document represents the value from the underlying 
  RawCurrencyValueSourceas converted to the specified target 
 Currency. | 
| static Currency | getCurrency(String code)A wrapper arround  Currency.getInstancethat returns null
 instead of throwingIllegalArgumentExceptionif the specified Currency does not exist in this JVM. | 
| Query | getFieldQuery(QParser parser,
             SchemaField field,
             String externalVal)Returns a Query instance for doing searches against a field. | 
| ExchangeRateProvider | getProvider() | 
| Query | getRangeQuery(QParser parser,
             SchemaField field,
             org.apache.solr.schema.CurrencyValue p1,
             org.apache.solr.schema.CurrencyValue p2,
             boolean minInclusive,
             boolean maxInclusive) | 
| 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. | 
| SortField | getSortField(SchemaField field,
            boolean reverse)Returns the SortField instance that should be used to sort fields
 of this type. | 
| UninvertingReader.Type | getUninversionType(SchemaField sf)If DocValues is not enabled for a field, but it's indexed, docvalues can be constructed 
 on the fly (uninverted, aka fieldcache) on the first request to sort, facet, etc. | 
| org.apache.solr.schema.CurrencyField.RawCurrencyValueSource | getValueSource(SchemaField field,
              QParser parser)
 Returns a ValueSource over this field in which the numeric value for 
 each document represents the indexed value as converted to the default 
 currency for the field, normalized to its most granular form based 
 on the default fractional digits. | 
| void | inform(IndexSchema schema)When index schema is informed, add dynamic fields "*____currency" and "*____amount_raw". | 
| void | inform(ResourceLoader resourceLoader)Load the currency config when resource loader initialized. | 
| protected void | init(IndexSchema schema,
    Map<String,String> args)subclasses should initialize themselves with the args provided
 and remove valid arguments. | 
| boolean | isPolyField()A "polyField" is a FieldType that can produce more than one IndexableField instance for a single value, via the  FieldType.createFields(org.apache.solr.schema.SchemaField, Object, float)method. | 
| void | write(TextResponseWriter writer,
     String name,
     IndexableField field)calls back to TextResponseWriter to write the field value | 
checkSupportsDocValues, createField, createField, getAnalyzerProperties, getClassArg, getDocValuesFormat, getIndexAnalyzer, getIndexOptions, getNamedPropertyValues, getNonFieldPropertyArgs, getNumberType, getNumericType, getPostingsFormat, getPrefixQuery, getQueryAnalyzer, getRewriteMethod, getSetQuery, getSimilarity, getSimilarityFactory, getSingleValueSource, getStringSort, getTypeName, hasProperty, indexedToReadable, indexedToReadable, isExplicitAnalyzer, isExplicitQueryAnalyzer, isMultiValued, isPointField, isTokenized, marshalBase64SortValue, marshalSortValue, marshalStringSortValue, multiValuedFieldCache, readableToIndexed, readableToIndexed, restrictProps, setArgs, setIndexAnalyzer, setIsExplicitAnalyzer, setIsExplicitQueryAnalyzer, setQueryAnalyzer, setSimilarity, storedToIndexed, storedToReadable, supportsAnalyzers, toExternal, toInternal, toNativeType, toObject, toObject, toString, unmarshalBase64SortValue, unmarshalSortValue, unmarshalStringSortValue, useDocValuesAsStoredprotected static final String PARAM_DEFAULT_CURRENCY
protected static final String PARAM_RATE_PROVIDER_CLASS
protected static final Object PARAM_PRECISION_STEP
protected static final String DEFAULT_RATE_PROVIDER_CLASS
protected static final String DEFAULT_DEFAULT_CURRENCY
protected static final String DEFAULT_PRECISION_STEP
protected static final String FIELD_SUFFIX_AMOUNT_RAW
protected static final String FIELD_SUFFIX_CURRENCY
protected FieldType fieldTypeCurrency
protected FieldType fieldTypeAmountRaw
public static Currency getCurrency(String code)
Currency.getInstance that returns null
 instead of throwing IllegalArgumentException
 if the specified Currency does not exist in this JVM.Currency.getInstance(String)protected void init(IndexSchema schema, Map<String,String> args)
FieldTypepublic boolean isPolyField()
FieldTypeFieldType.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.isPolyField in class FieldTypeFieldType.createFields(org.apache.solr.schema.SchemaField, Object, float) method may return more than one fieldpublic void checkSchemaField(SchemaField field) throws SolrException
FieldTypeSchemaField instances constructed 
 using this field type to ensure that they are valid.
 
 This method is called by the SchemaField constructor to 
 check that its initialization does not violate any fundamental
 requirements of the FieldType.
 Subclasses may choose to throw a SolrException
 if invariants are violated by the SchemaField.
 
checkSchemaField in class FieldTypeSolrExceptionpublic List<IndexableField> createFields(SchemaField field, Object externalVal, float boost)
FieldTypeSchemaField, create one or more IndexableField instancescreateFields in class FieldTypefield - the SchemaFieldexternalVal - The value to add to the fieldboost - The boost to applyIndexableFieldFieldType.createField(SchemaField, Object, float), 
FieldType.isPolyField()public void inform(IndexSchema schema)
IndexSchema provided by the schema
 parameter of an event (e.g., a new FieldType was added, etc.inform in interface SchemaAwareschema - The IndexSchema instance that inform of the update to.public void inform(ResourceLoader resourceLoader)
inform in interface ResourceLoaderAwareresourceLoader - The resource loader.public Query getFieldQuery(QParser parser, SchemaField field, String externalVal)
FieldTypegetFieldQuery in class FieldTypeparser - The QParser calling the methodfield - The SchemaField of the field to searchexternalVal - The String representation of the value to searchQuery instance.  This implementation returns a TermQuery but overriding queries may notpublic org.apache.solr.schema.CurrencyField.RawCurrencyValueSource getValueSource(SchemaField field, QParser parser)
Returns a ValueSource over this field in which the numeric value for each document represents the indexed value as converted to the default currency for the field, normalized to its most granular form based on the default fractional digits.
 For example: If the default Currency specified for a field is 
 USD, then the values returned by this value source would 
 represent the equivilent number of "cents" (ie: value in dollars * 100) 
 after converting each document's native currency to USD -- because the 
 default fractional digits for USD is "2".  
 So for a document whose indexed value was currently equivilent to 
 "5.43,USD" using the the exchange provider for this field, 
 this ValueSource would return a value of "543"
 
public ValueSource getConvertedValueSource(String targetCurrencyCode, org.apache.solr.schema.CurrencyField.RawCurrencyValueSource source)
 Returns a ValueSource over this field in which the numeric value for 
 each document represents the value from the underlying 
 RawCurrencyValueSource as converted to the specified target 
 Currency.
 
 For example: If the targetCurrencyCode param is set to
 USD, then the values returned by this value source would 
 represent the equivilent number of dollars after converting each 
 document's raw value to USD.  So for a document whose 
 indexed value was currently equivilent to "5.43,USD" 
 using the the exchange provider for this field, this ValueSource would 
 return a value of "5.43"
 
targetCurrencyCode - The target currency for the resulting value source, if null the defaultCurrency for this field type will be usedsource - the raw ValueSource to wrapPARAM_DEFAULT_CURRENCY, 
DEFAULT_DEFAULT_CURRENCY, 
getValueSource(org.apache.solr.schema.SchemaField, org.apache.solr.search.QParser)public Query getRangeQuery(QParser parser, SchemaField field, String part1, String part2, boolean minInclusive, boolean maxInclusive)
FieldTypeSolrQueryParser
 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.
getRangeQuery in class FieldTypeparser - the QParser calling the methodfield - 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 notpublic Query getRangeQuery(QParser parser, SchemaField field, org.apache.solr.schema.CurrencyValue p1, org.apache.solr.schema.CurrencyValue p2, boolean minInclusive, boolean maxInclusive)
public SortField getSortField(SchemaField field, boolean reverse)
FieldTypegetSortField in class FieldTypeSchemaField.checkSortability()public UninvertingReader.Type getUninversionType(SchemaField sf)
FieldTypegetUninversionType in class FieldTypesf - field instancenull (to disallow uninversion for the field)public void write(TextResponseWriter writer, String name, IndexableField field) throws IOException
FieldTypewrite in class FieldTypeIOExceptionpublic ExchangeRateProvider getProvider()
Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.