Class AbstractSpatialFieldType<T extends org.apache.lucene.spatial.SpatialStrategy>

    • Field Detail


        public static final String FILTER_PARAM
        A local-param boolean that can be set to false to only return the FunctionQuery (score), and thus not do filtering.
        See Also:
        Constant Field Values
      • ctx

        protected org.locationtech.spatial4j.context.SpatialContext ctx
      • argsParser

        protected org.apache.lucene.spatial.query.SpatialArgsParser argsParser
      • shapeWriter

        protected shapeWriter
      • shapeReader

        protected shapeReader
      • supportedScoreModes

        protected final Set<String> supportedScoreModes
    • Constructor Detail

      • AbstractSpatialFieldType

        protected AbstractSpatialFieldType()
      • AbstractSpatialFieldType

        protected AbstractSpatialFieldType​(Set<String> moreScoreModes)
    • Method Detail

      • init

        protected void init​(IndexSchema schema,
                            Map<String,​String> args)
        Description copied from class: FieldType
        subclasses should initialize themselves with the args provided and remove valid arguments. leftover arguments will cause an exception. Common boolean properties have already been handled.
        init in class FieldType
      • newSpatialArgsParser

        protected org.apache.lucene.spatial.query.SpatialArgsParser newSpatialArgsParser()
      • createField

        public final org.apache.lucene.document.Field createField​(SchemaField field,
                                                                  Object val)
        Description copied from class: FieldType
        Used for adding a document when a field needs to be created from a type and a string.

        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.
        createField in class FieldType
        See Also:
      • getUninversionType

        public UninvertingReader.Type getUninversionType​(SchemaField sf)
        Description copied from class: FieldType

        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. This specifies the structure to use.

        This method will not be used if the field is (effectively) uninvertible="false"

        Specified by:
        getUninversionType in class FieldType
        sf - field instance
        type to uninvert, or null (to disallow uninversion for the field)
        See Also:
      • parseShape

        public org.locationtech.spatial4j.shape.Shape parseShape​(String str)
        Create a Shape from the input string
      • shapeToString

        public String shapeToString​(org.locationtech.spatial4j.shape.Shape shape)
        Returns a String version of a shape to be used for the stored value. The format can be selected using the initParam format={WKT|GeoJSON}
      • newSpatialStrategy

        protected abstract T newSpatialStrategy​(String fieldName)
        Called from getStrategy(String) upon first use by fieldName. }
      • getSpecializedRangeQuery

        protected getSpecializedRangeQuery​(QParser parser,
                                                                          SchemaField field,
                                                                          String part1,
                                                                          String part2,
                                                                          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.

        This method does not, and should not, check for or handle existence queries, please look at FieldType.getRangeQuery(, org.apache.solr.schema.SchemaField, java.lang.String, java.lang.String, boolean, boolean) for that logic.

        getSpecializedRangeQuery in class FieldType
        parser - the QParser calling the method
        field - the schema field
        part1 - the lower boundary of the range, nulls are allowed.
        part2 - 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
        a Query instance to perform range search according to given parameters
      • getValueSource

        public org.apache.lucene.queries.function.ValueSource getValueSource​(SchemaField field,
                                                                             QParser parser)
        Description copied from class: FieldType
        called to get the default value source (normally, from the Lucene FieldCache.)
        getValueSource in class FieldType
      • getFieldQuery

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

        protected org.apache.lucene.spatial.query.SpatialArgs parseSpatialArgs​(QParser parser,
                                                                               String externalVal)
      • getQueryFromSpatialArgs

        protected getQueryFromSpatialArgs​(QParser parser,
                                                                         SchemaField field,
                                                                         org.apache.lucene.spatial.query.SpatialArgs spatialArgs)
      • getSupportedScoreModes

        public Set<String> getSupportedScoreModes()
        The set of values supported for the score local-param. Not null.
      • getValueSourceFromSpatialArgs

        protected getValueSourceFromSpatialArgs​(QParser parser,
                                                                                            SchemaField field,
                                                                                            org.apache.lucene.spatial.query.SpatialArgs spatialArgs,
                                                                                            String score,
                                                                                            T strategy)
      • getStrategy

        public T getStrategy​(String fieldName)
        Gets the cached strategy for this field, creating it if necessary via newSpatialStrategy(String).
        fieldName - Mandatory reference to the field name
      • getSpatialContext

        public org.locationtech.spatial4j.context.SpatialContext getSpatialContext()
        The Spatial Context for this field type