Class DocValues


  • public final class DocValues
    extends java.lang.Object
    This class contains utility methods and constants for DocValues
    • Constructor Detail

      • DocValues

        private DocValues()
    • Method Detail

      • emptyNumeric

        public static final NumericDocValues emptyNumeric()
        An empty NumericDocValues which returns no documents
      • emptySortedNumeric

        public static final SortedNumericDocValues emptySortedNumeric()
        An empty SortedNumericDocValues which returns zero values for every document
      • checkField

        private static void checkField​(LeafReader in,
                                       java.lang.String field,
                                       DocValuesType... expected)
      • getNumeric

        public static NumericDocValues getNumeric​(LeafReader reader,
                                                  java.lang.String field)
                                           throws java.io.IOException
        Returns NumericDocValues for the field, or emptyNumeric() if it has none.
        Returns:
        docvalues instance, or an empty instance if field does not exist in this reader.
        Throws:
        java.lang.IllegalStateException - if field exists, but was not indexed with docvalues.
        java.lang.IllegalStateException - if field has docvalues, but the type is not DocValuesType.NUMERIC.
        java.io.IOException - if an I/O error occurs.
      • getBinary

        public static BinaryDocValues getBinary​(LeafReader reader,
                                                java.lang.String field)
                                         throws java.io.IOException
        Returns BinaryDocValues for the field, or emptyBinary() if it has none.
        Returns:
        docvalues instance, or an empty instance if field does not exist in this reader.
        Throws:
        java.lang.IllegalStateException - if field exists, but was not indexed with docvalues.
        java.lang.IllegalStateException - if field has docvalues, but the type is not DocValuesType.BINARY.
        java.io.IOException - if an I/O error occurs.
      • getSorted

        public static SortedDocValues getSorted​(LeafReader reader,
                                                java.lang.String field)
                                         throws java.io.IOException
        Returns SortedDocValues for the field, or emptySorted() if it has none.
        Returns:
        docvalues instance, or an empty instance if field does not exist in this reader.
        Throws:
        java.lang.IllegalStateException - if field exists, but was not indexed with docvalues.
        java.lang.IllegalStateException - if field has docvalues, but the type is not DocValuesType.SORTED.
        java.io.IOException - if an I/O error occurs.
      • getSortedNumeric

        public static SortedNumericDocValues getSortedNumeric​(LeafReader reader,
                                                              java.lang.String field)
                                                       throws java.io.IOException
        Returns SortedNumericDocValues for the field, or emptySortedNumeric() if it has none.
        Returns:
        docvalues instance, or an empty instance if field does not exist in this reader.
        Throws:
        java.lang.IllegalStateException - if field exists, but was not indexed with docvalues.
        java.lang.IllegalStateException - if field has docvalues, but the type is not DocValuesType.SORTED_NUMERIC or DocValuesType.NUMERIC.
        java.io.IOException - if an I/O error occurs.
      • getSortedSet

        public static SortedSetDocValues getSortedSet​(LeafReader reader,
                                                      java.lang.String field)
                                               throws java.io.IOException
        Returns SortedSetDocValues for the field, or emptySortedSet() if it has none.
        Returns:
        docvalues instance, or an empty instance if field does not exist in this reader.
        Throws:
        java.lang.IllegalStateException - if field exists, but was not indexed with docvalues.
        java.lang.IllegalStateException - if field has docvalues, but the type is not DocValuesType.SORTED_SET or DocValuesType.SORTED.
        java.io.IOException - if an I/O error occurs.
      • isCacheable

        public static boolean isCacheable​(LeafReaderContext ctx,
                                          java.lang.String... fields)
        Returns true if the specified docvalues fields have not been updated