Class PreAnalyzedField

    • Constructor Detail

      • PreAnalyzedField

        public PreAnalyzedField()
    • Method Detail

      • init

        public 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.
        Overrides:
        init in class TextField
      • getIndexAnalyzer

        public org.apache.lucene.analysis.Analyzer getIndexAnalyzer()
        Overridden to return an analyzer consisting of a PreAnalyzedField.PreAnalyzedTokenizer. NOTE: If an index analyzer is specified in the schema, it will be ignored.
        Overrides:
        getIndexAnalyzer in class FieldType
        See Also:
        FieldType.getQueryAnalyzer()
      • getQueryAnalyzer

        public org.apache.lucene.analysis.Analyzer getQueryAnalyzer()
        Returns the query analyzer defined via the schema, unless there is none, in which case the index-time pre-analyzer is returned. Note that if the schema specifies an index-time analyzer via either <analyzer> or <analyzer type="index">, but no query-time analyzer, the query analyzer returned here will be the index-time analyzer specified in the schema rather than the pre-analyzer.
        Overrides:
        getQueryAnalyzer in class FieldType
        See Also:
        FieldType.getIndexAnalyzer()
      • createField

        public org.apache.lucene.index.IndexableField createField​(SchemaField field,
                                                                  Object value)
        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.
        Overrides:
        createField in class FieldType
        See Also:
        FieldType.toInternal(java.lang.String)
      • 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.)
        Overrides:
        getValueSource in class TextField
      • 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"

        Overrides:
        getUninversionType in class TextField
        Parameters:
        sf - field instance
        Returns:
        type to uninvert, or null (to disallow uninversion for the field)
        See Also:
        SchemaField.isUninvertible()
      • toFormattedString

        public String toFormattedString​(org.apache.lucene.document.Field f)
                                 throws IOException
        Utility method to convert a field to a string that is parse-able by this class.
        Parameters:
        f - field to convert
        Returns:
        string that is compatible with the serialization format
        Throws:
        IOException - If there is a low-level I/O error.
      • createFieldType

        public static org.apache.lucene.document.FieldType createFieldType​(SchemaField field)
        Utility method to create a FieldType based on the SchemaField