org.apache.lucene.document

## Class SortedDocValuesField

- java.lang.Object
- - org.apache.lucene.document.Field
  - - org.apache.lucene.document.SortedDocValuesField

- All Implemented Interfaces:
    IndexableField

      public class SortedDocValuesField
      extends Field

  Field that stores a per-document `BytesRef` value, indexed for sorting. Here's an example usage:

         document.add(new SortedDocValuesField(name, new BytesRef("hello")));

  If you also need to store the value, you should add a separate `StoredField` instance.

  This value can be at most 32766 bytes long.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.lucene.document.Field

      `Field.Store`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static FieldType` | `TYPE` Type for sorted bytes DocValues

    - ### Fields inherited from class org.apache.lucene.document.Field

      `fieldsData, name, tokenStream, type`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SortedDocValuesField(String name, BytesRef bytes)` Create a new sorted DocValues field.

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Query` | `newSlowExactQuery(String field, BytesRef value)` Create a query for matching an exact `BytesRef` value.
    `static Query` | `newSlowRangeQuery(String field, BytesRef lowerValue, BytesRef upperValue, boolean lowerInclusive, boolean upperInclusive)` Create a range query that matches all documents whose value is between `lowerValue` and `upperValue` included.

    - ### Methods inherited from class org.apache.lucene.document.Field

      `binaryValue, fieldType, name, numericValue, readerValue, setBytesValue, setBytesValue, setByteValue, setDoubleValue, setFloatValue, setIntValue, setLongValue, setReaderValue, setShortValue, setStringValue, setTokenStream, stringValue, tokenStream, tokenStreamValue, toString`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### TYPE

          public static final FieldType TYPE

      Type for sorted bytes DocValues

  - ### Constructor Detail

    - #### SortedDocValuesField

          public SortedDocValuesField(String name,
                                      BytesRef bytes)

      Create a new sorted DocValues field.
      Parameters:
        `name` - field name
        `bytes` - binary content
      Throws:
        `IllegalArgumentException` - if the field name is null

  - ### Method Detail

    - #### newSlowRangeQuery

          public static Query newSlowRangeQuery(String field,
                                                BytesRef lowerValue,
                                                BytesRef upperValue,
                                                boolean lowerInclusive,
                                                boolean upperInclusive)

      Create a range query that matches all documents whose value is between `lowerValue` and `upperValue` included.

      You can have half-open ranges by setting `lowerValue = null` or `upperValue = null`.

      NOTE: Such queries cannot efficiently advance to the next match, which makes them slow if they are not ANDed with a selective query. As a consequence, they are best used wrapped in an `IndexOrDocValuesQuery`, alongside a range query that executes on points, such as `BinaryPoint.newRangeQuery(java.lang.String, byte[], byte[])`.

    - #### newSlowExactQuery

          public static Query newSlowExactQuery(String field,
                                                BytesRef value)

      Create a query for matching an exact `BytesRef` value.

      NOTE: Such queries cannot efficiently advance to the next match, which makes them slow if they are not ANDed with a selective query. As a consequence, they are best used wrapped in an `IndexOrDocValuesQuery`, alongside a range query that executes on points, such as `BinaryPoint.newExactQuery(java.lang.String, byte[])`.

Copyright © 2000-2018 Apache Software Foundation. All Rights Reserved.