Class PointField

  • Direct Known Subclasses:
    DatePointField, DoublePointField, FloatPointField, IntPointField, LongPointField

    public abstract class PointField
    extends NumericFieldType
    Provides field types to support for Lucene's IntPoint, LongPoint, FloatPoint and DoublePoint. See PointRangeQuery for more details. It supports integer, float, long and double types. See subclasses for details.
    DocValues are supported for single-value cases (NumericDocValues). FieldCache is not supported for PointFields, so sorting, faceting, etc on these fields require the use of docValues="true" in the schema.
    • Field Detail

      • TEST_HACK_IGNORE_USELESS_TRIEFIELD_ARGS

        public static boolean TEST_HACK_IGNORE_USELESS_TRIEFIELD_ARGS

        The Test framework can set this global variable to instruct PointField that (on init) it should be tollerant of the precisionStep argument used by TrieFields. This allows for simple randomization of TrieFields and PointFields w/o extensive duplication of <fieldType/> declarations.

        NOTE: When TrieField is removed, this boolean must also be removed

        WARNING: This API is experimental and might change in incompatible ways in the next release.
        NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
    • Constructor Detail

      • PointField

        public PointField()
    • Method Detail

      • getSingleValueSource

        protected abstract org.apache.lucene.queries.function.ValueSource getSingleValueSource​(org.apache.lucene.search.SortedNumericSelector.Type choice,
                                                                                               SchemaField field)
        Helper method that will only be called for multivalued Point fields that have doc values. Default impl throws an error indicating that selecting a single value from this multivalued field is not supported for this field type
        Parameters:
        choice - the selector Type to use, will never be null
        field - the field to use, guaranteed to be multivalued.
        See Also:
        getSingleValueSource(MultiValueSelector,SchemaField,QParser)
      • isTokenized

        public boolean isTokenized()
        Description copied from class: FieldType
        Returns true if fields of this type should be tokenized
        Overrides:
        isTokenized in class FieldType
      • multiValuedFieldCache

        public boolean multiValuedFieldCache()
        Description copied from class: FieldType
        Returns true if a single field value of this type has multiple logical values for the purposes of faceting, sorting, etc. Text fields normally return true since each token/word is a logical value.
        Overrides:
        multiValuedFieldCache in class FieldType
      • getFieldQuery

        public org.apache.lucene.search.Query getFieldQuery​(QParser parser,
                                                            SchemaField field,
                                                            String externalVal)
        Description copied from class: FieldType
        Returns a Query instance for doing searches against a field.
        Overrides:
        getFieldQuery in class FieldType
        Parameters:
        parser - The QParser calling the method
        field - The SchemaField of the field to search
        externalVal - The String representation of the value to search
        Returns:
        The Query instance. This implementation returns a TermQuery but overriding queries may not
      • getExactQuery

        protected abstract org.apache.lucene.search.Query getExactQuery​(SchemaField field,
                                                                        String externalVal)
      • getPointRangeQuery

        public abstract org.apache.lucene.search.Query getPointRangeQuery​(QParser parser,
                                                                          SchemaField field,
                                                                          String min,
                                                                          String max,
                                                                          boolean minInclusive,
                                                                          boolean maxInclusive)
      • getRangeQuery

        public org.apache.lucene.search.Query getRangeQuery​(QParser parser,
                                                            SchemaField field,
                                                            String min,
                                                            String max,
                                                            boolean minInclusive,
                                                            boolean maxInclusive)
        Description copied from class: FieldType
        Returns a Query instance for doing range searches on this field type. 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.

        Overrides:
        getRangeQuery in class FieldType
        Parameters:
        parser - the QParser calling the method
        field - the schema field
        min - the lower boundary of the range, nulls are allowed.
        max - the upper boundary of the range, nulls are allowed
        minInclusive - whether the minimum of the range is inclusive or not
        maxInclusive - whether the maximum of the range is inclusive or not
        Returns:
        a Query instance to perform range search according to given parameters
      • storedToReadable

        public String storedToReadable​(org.apache.lucene.index.IndexableField f)
        Description copied from class: FieldType
        Given the stored field, return the human readable representation
        Overrides:
        storedToReadable in class FieldType
      • toInternalByteRef

        public org.apache.lucene.util.BytesRef toInternalByteRef​(String val)
      • storedToIndexed

        public String storedToIndexed​(org.apache.lucene.index.IndexableField f)
        Description copied from class: FieldType
        Given the stored field, return the indexed form
        Overrides:
        storedToIndexed in class FieldType
      • indexedToReadable

        public org.apache.lucene.util.CharsRef indexedToReadable​(org.apache.lucene.util.BytesRef indexedForm,
                                                                 org.apache.lucene.util.CharsRefBuilder charsRef)
        Description copied from class: FieldType
        Given an indexed term, append the human readable representation
        Overrides:
        indexedToReadable in class FieldType
      • indexedToReadable

        protected abstract String indexedToReadable​(org.apache.lucene.util.BytesRef indexedForm)
      • getPrefixQuery

        public org.apache.lucene.search.Query getPrefixQuery​(QParser parser,
                                                             SchemaField sf,
                                                             String termStr)
        Description copied from class: FieldType
        Returns a Query instance for doing prefix searches on this field type. Also, other QueryParser implementations may have different semantics.

        Sub-classes should override this method to provide their own range query implementation.

        Overrides:
        getPrefixQuery in class FieldType
        Parameters:
        parser - the QParser calling the method
        sf - the schema field
        termStr - the term string for prefix query
        Returns:
        a Query instance to perform prefix search
      • isFieldUsed

        protected boolean isFieldUsed​(SchemaField field)
      • getStoredField

        protected abstract org.apache.lucene.document.StoredField getStoredField​(SchemaField sf,
                                                                                 Object value)