Class MappedFieldType

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  MappedFieldType.Relation
      An enum used to describe the relation between the range of terms in a shard when compared with a query range
    • Method Summary

      Modifier and Type Method Description
      float boost()  
      void checkCompatibility​(MappedFieldType other, java.util.List<java.lang.String> conflicts, boolean strict)
      Checks for any conflicts between this field type and other.
      abstract MappedFieldType clone()  
      DocValueFormat docValueFormat​(java.lang.String format, org.joda.time.DateTimeZone timeZone)
      Return a DocValueFormat that can be used to display and parse values as returned by the fielddata API.
      boolean eagerGlobalOrdinals()  
      boolean equals​(java.lang.Object o)  
      abstract org.apache.lucene.search.Query existsQuery​(QueryShardContext context)  
      static org.apache.lucene.index.Term extractTerm​(org.apache.lucene.search.Query termQuery)
      Extract a Term from a query created with termQuery(java.lang.Object, org.elasticsearch.index.query.QueryShardContext) by recursively removing BoostQuery wrappers.
      protected void failIfNoDocValues()  
      protected void failIfNotIndexed()  
      IndexFieldData.Builder fielddataBuilder​(java.lang.String fullyQualifiedIndexName)
      Return a fielddata builder for this field
      org.apache.lucene.search.Query fuzzyQuery​(java.lang.Object value, Fuzziness fuzziness, int prefixLength, int maxExpansions, boolean transpositions)  
      boolean hasDocValues()  
      int hashCode()  
      NamedAnalyzer indexAnalyzer()  
      boolean isAggregatable()
      Returns true if the field is aggregatable.
      MappedFieldType.Relation isFieldWithinQuery​(org.apache.lucene.index.IndexReader reader, java.lang.Object from, java.lang.Object to, boolean includeLower, boolean includeUpper, org.joda.time.DateTimeZone timeZone, DateMathParser dateMathParser, QueryRewriteContext context)
      Return whether all values of the given IndexReader are within the range, outside the range or cross the range.
      boolean isSearchable()
      Returns true if the field is searchable.
      org.apache.lucene.search.Query multiPhraseQuery​(org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements)  
      java.lang.String name()  
      java.lang.Object nullValue()
      Returns the value that should be added when JSON null is found, or null if no value should be added
      java.lang.String nullValueAsString()
      Returns the null value stringified, so it can be used for e.g.
      org.apache.lucene.search.Query nullValueQuery()  
      org.apache.lucene.search.Query phrasePrefixQuery​(org.apache.lucene.analysis.TokenStream stream, int slop, int maxExpansions)  
      org.apache.lucene.search.Query phraseQuery​(org.apache.lucene.analysis.TokenStream stream, int slop, boolean enablePositionIncrements)  
      org.apache.lucene.search.Query prefixQuery​(java.lang.String value, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)  
      org.apache.lucene.search.Query queryStringTermQuery​(org.apache.lucene.index.Term term)
      A term query to use when parsing a query string.
      org.apache.lucene.search.Query rangeQuery​(java.lang.Object lowerTerm, java.lang.Object upperTerm, boolean includeLower, boolean includeUpper, ShapeRelation relation, org.joda.time.DateTimeZone timeZone, DateMathParser parser, QueryShardContext context)
      Factory method for range queries.
      org.apache.lucene.search.Query regexpQuery​(java.lang.String value, int flags, int maxDeterminizedStates, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)  
      NamedAnalyzer searchAnalyzer()  
      NamedAnalyzer searchQuoteAnalyzer()  
      void setBoost​(float boost)  
      void setEagerGlobalOrdinals​(boolean eagerGlobalOrdinals)  
      void setHasDocValues​(boolean hasDocValues)  
      void setIndexAnalyzer​(NamedAnalyzer analyzer)  
      void setName​(java.lang.String name)  
      void setNullValue​(java.lang.Object nullValue)
      Sets the null value and initializes the string version
      void setSearchAnalyzer​(NamedAnalyzer analyzer)  
      void setSearchQuoteAnalyzer​(NamedAnalyzer analyzer)  
      void setSimilarity​(SimilarityProvider similarity)  
      SimilarityProvider similarity()  
      org.apache.lucene.search.spans.SpanQuery spanPrefixQuery​(java.lang.String value, org.apache.lucene.search.spans.SpanMultiTermQueryWrapper.SpanRewriteMethod method, QueryShardContext context)  
      abstract org.apache.lucene.search.Query termQuery​(java.lang.Object value, QueryShardContext context)
      Generates a query that will only match documents that contain the given value.
      org.apache.lucene.search.Query termsQuery​(java.util.List<?> values, QueryShardContext context)
      Build a constant-scoring query that matches all values.
      abstract java.lang.String typeName()
      Returns the name of this type, as would be specified in mapping properties
      java.lang.Object valueForDisplay​(java.lang.Object value)
      Given a value that comes from the stored fields API, convert it to the expected type.
      org.apache.lucene.search.Query wildcardQuery​(java.lang.String value, org.apache.lucene.search.MultiTermQuery.RewriteMethod method, QueryShardContext context)  
      • Methods inherited from class org.apache.lucene.document.FieldType

        checkIfFrozen, docValuesType, freeze, getAttributes, indexOptions, omitNorms, pointDataDimensionCount, pointIndexDimensionCount, pointNumBytes, putAttribute, setDimensions, setDimensions, setDocValuesType, setIndexOptions, setOmitNorms, setStored, setStoreTermVectorOffsets, setStoreTermVectorPayloads, setStoreTermVectorPositions, setStoreTermVectors, setTokenized, stored, storeTermVectorOffsets, storeTermVectorPayloads, storeTermVectorPositions, storeTermVectors, tokenized, toString
      • Methods inherited from class java.lang.Object

        finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • MappedFieldType

        public MappedFieldType()
    • Method Detail

      • clone

        public abstract MappedFieldType clone()
        Overrides:
        clone in class java.lang.Object
      • fielddataBuilder

        public IndexFieldData.Builder fielddataBuilder​(java.lang.String fullyQualifiedIndexName)
        Return a fielddata builder for this field
        Parameters:
        fullyQualifiedIndexName - the name of the index this field-data is build for
        Throws:
        java.lang.IllegalArgumentException - if the fielddata is not supported on this type. An IllegalArgumentException is needed in order to return an http error 400 when this error occurs in a request. see: ExceptionsHelper.status(java.lang.Throwable)
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class org.apache.lucene.document.FieldType
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class org.apache.lucene.document.FieldType
      • typeName

        public abstract java.lang.String typeName()
        Returns the name of this type, as would be specified in mapping properties
      • checkCompatibility

        public void checkCompatibility​(MappedFieldType other,
                                       java.util.List<java.lang.String> conflicts,
                                       boolean strict)
        Checks for any conflicts between this field type and other. If strict is true, all properties must be equal. Otherwise, only properties which must never change in an index are checked.
      • name

        public java.lang.String name()
      • setName

        public void setName​(java.lang.String name)
      • boost

        public float boost()
      • setBoost

        public void setBoost​(float boost)
      • hasDocValues

        public boolean hasDocValues()
      • setHasDocValues

        public void setHasDocValues​(boolean hasDocValues)
      • setIndexAnalyzer

        public void setIndexAnalyzer​(NamedAnalyzer analyzer)
      • setSearchAnalyzer

        public void setSearchAnalyzer​(NamedAnalyzer analyzer)
      • searchQuoteAnalyzer

        public NamedAnalyzer searchQuoteAnalyzer()
      • setSearchQuoteAnalyzer

        public void setSearchQuoteAnalyzer​(NamedAnalyzer analyzer)
      • nullValue

        public java.lang.Object nullValue()
        Returns the value that should be added when JSON null is found, or null if no value should be added
      • nullValueAsString

        public java.lang.String nullValueAsString()
        Returns the null value stringified, so it can be used for e.g. _all field, or null if there is no null value
      • setNullValue

        public void setNullValue​(java.lang.Object nullValue)
        Sets the null value and initializes the string version
      • valueForDisplay

        public java.lang.Object valueForDisplay​(java.lang.Object value)
        Given a value that comes from the stored fields API, convert it to the expected type. For instance a date field would store dates as longs and format it back to a string in this method.
      • isSearchable

        public boolean isSearchable()
        Returns true if the field is searchable.
      • isAggregatable

        public boolean isAggregatable()
        Returns true if the field is aggregatable.
      • termQuery

        public abstract org.apache.lucene.search.Query termQuery​(java.lang.Object value,
                                                                 @Nullable
                                                                 QueryShardContext context)
        Generates a query that will only match documents that contain the given value. The default implementation returns a TermQuery over the value bytes, boosted by boost().
        Throws:
        java.lang.IllegalArgumentException - if value cannot be converted to the expected data type or if the field is not searchable due to the way it is configured (eg. not indexed)
        ElasticsearchParseException - if value cannot be converted to the expected data type
        java.lang.UnsupportedOperationException - if the field is not searchable regardless of options
        QueryShardException - if the field is not searchable regardless of options
      • rangeQuery

        public org.apache.lucene.search.Query rangeQuery​(java.lang.Object lowerTerm,
                                                         java.lang.Object upperTerm,
                                                         boolean includeLower,
                                                         boolean includeUpper,
                                                         ShapeRelation relation,
                                                         org.joda.time.DateTimeZone timeZone,
                                                         DateMathParser parser,
                                                         QueryShardContext context)
        Factory method for range queries.
        Parameters:
        relation - the relation, nulls should be interpreted like INTERSECTS
      • fuzzyQuery

        public org.apache.lucene.search.Query fuzzyQuery​(java.lang.Object value,
                                                         Fuzziness fuzziness,
                                                         int prefixLength,
                                                         int maxExpansions,
                                                         boolean transpositions)
      • prefixQuery

        public org.apache.lucene.search.Query prefixQuery​(java.lang.String value,
                                                          @Nullable
                                                          org.apache.lucene.search.MultiTermQuery.RewriteMethod method,
                                                          QueryShardContext context)
      • wildcardQuery

        public org.apache.lucene.search.Query wildcardQuery​(java.lang.String value,
                                                            @Nullable
                                                            org.apache.lucene.search.MultiTermQuery.RewriteMethod method,
                                                            QueryShardContext context)
      • regexpQuery

        public org.apache.lucene.search.Query regexpQuery​(java.lang.String value,
                                                          int flags,
                                                          int maxDeterminizedStates,
                                                          @Nullable
                                                          org.apache.lucene.search.MultiTermQuery.RewriteMethod method,
                                                          QueryShardContext context)
      • nullValueQuery

        public org.apache.lucene.search.Query nullValueQuery()
      • existsQuery

        public abstract org.apache.lucene.search.Query existsQuery​(QueryShardContext context)
      • phraseQuery

        public org.apache.lucene.search.Query phraseQuery​(org.apache.lucene.analysis.TokenStream stream,
                                                          int slop,
                                                          boolean enablePositionIncrements)
                                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • multiPhraseQuery

        public org.apache.lucene.search.Query multiPhraseQuery​(org.apache.lucene.analysis.TokenStream stream,
                                                               int slop,
                                                               boolean enablePositionIncrements)
                                                        throws java.io.IOException
        Throws:
        java.io.IOException
      • phrasePrefixQuery

        public org.apache.lucene.search.Query phrasePrefixQuery​(org.apache.lucene.analysis.TokenStream stream,
                                                                int slop,
                                                                int maxExpansions)
                                                         throws java.io.IOException
        Throws:
        java.io.IOException
      • spanPrefixQuery

        public org.apache.lucene.search.spans.SpanQuery spanPrefixQuery​(java.lang.String value,
                                                                        org.apache.lucene.search.spans.SpanMultiTermQueryWrapper.SpanRewriteMethod method,
                                                                        QueryShardContext context)
      • isFieldWithinQuery

        public MappedFieldType.Relation isFieldWithinQuery​(org.apache.lucene.index.IndexReader reader,
                                                           java.lang.Object from,
                                                           java.lang.Object to,
                                                           boolean includeLower,
                                                           boolean includeUpper,
                                                           org.joda.time.DateTimeZone timeZone,
                                                           DateMathParser dateMathParser,
                                                           QueryRewriteContext context)
                                                    throws java.io.IOException
        Return whether all values of the given IndexReader are within the range, outside the range or cross the range. The default implementation returns MappedFieldType.Relation.INTERSECTS, which is always fine to return when there is no way to check whether values are actually within bounds.
        Throws:
        java.io.IOException
      • queryStringTermQuery

        @Nullable
        public org.apache.lucene.search.Query queryStringTermQuery​(org.apache.lucene.index.Term term)
        A term query to use when parsing a query string. Can return null.
      • failIfNoDocValues

        protected final void failIfNoDocValues()
        Throws:
        java.lang.IllegalArgumentException - if the fielddata is not supported on this type. An IllegalArgumentException is needed in order to return an http error 400 when this error occurs in a request. see: ExceptionsHelper.status(java.lang.Throwable)
      • failIfNotIndexed

        protected final void failIfNotIndexed()
      • eagerGlobalOrdinals

        public boolean eagerGlobalOrdinals()
      • setEagerGlobalOrdinals

        public void setEagerGlobalOrdinals​(boolean eagerGlobalOrdinals)
      • docValueFormat

        public DocValueFormat docValueFormat​(@Nullable
                                             java.lang.String format,
                                             org.joda.time.DateTimeZone timeZone)
        Return a DocValueFormat that can be used to display and parse values as returned by the fielddata API. The default implementation returns a DocValueFormat.RAW.