org.apache.lucene.index

## Class SingletonSortedSetDocValues

- java.lang.Object
- - org.apache.lucene.index.SortedSetDocValues
  - - org.apache.lucene.index.SingletonSortedSetDocValues

    public class SingletonSortedSetDocValues
    extends SortedSetDocValues

Exposes multi-valued view over a single-valued instance.

This can be used if you want to have one multi-valued implementation against e.g. FieldCache.getDocTermOrds that also works for single-valued fields.

### Field Summary

### Fields inherited from class org.apache.lucene.index.SortedSetDocValues

`EMPTY, NO_MORE_ORDS`

### Constructor Summary

Constructors
Constructor and Description
`SingletonSortedSetDocValues(SortedDocValues in)` Creates a multi-valued view over the provided SortedDocValues

### Method Summary

Methods
`long` `getValueCount()` Returns the number of unique values.
`void` `lookupOrd(long ord, BytesRef result)` Retrieves the value for the specified ordinal.
`long` `lookupTerm(BytesRef key)` If `key` exists, returns its ordinal, else returns `-insertionPoint-1`, like `Arrays.binarySearch`.
`long` `nextOrd()` Returns the next ordinal for the current document (previously set by `SortedSetDocValues.setDocument(int)`.
`void` `setDocument(int docID)` Sets iteration to the specified docID

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

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

### Constructor Detail

#### SingletonSortedSetDocValues

    public SingletonSortedSetDocValues(SortedDocValues in)

Creates a multi-valued view over the provided SortedDocValues

### Method Detail

#### nextOrd

    public long nextOrd()

Description copied from class: `SortedSetDocValues`
Returns the next ordinal for the current document (previously set by `SortedSetDocValues.setDocument(int)`.

Specified by:
  `nextOrd` in class `SortedSetDocValues`
Returns:
  next ordinal for the document, or `SortedSetDocValues.NO_MORE_ORDS`. ordinals are dense, start at 0, then increment by 1 for the next value in sorted order.

#### setDocument

    public void setDocument(int docID)

Description copied from class: `SortedSetDocValues`
Sets iteration to the specified docID

Specified by:
  `setDocument` in class `SortedSetDocValues`
Parameters:
  `docID` - document ID

#### lookupOrd

    public void lookupOrd(long ord,
                 BytesRef result)

Description copied from class: `SortedSetDocValues`
Retrieves the value for the specified ordinal.

Specified by:
  `lookupOrd` in class `SortedSetDocValues`
Parameters:
  `ord` - ordinal to lookup
  `result` - will be populated with the ordinal's value
See Also:
  `SortedSetDocValues.nextOrd()`

#### getValueCount

    public long getValueCount()

Description copied from class: `SortedSetDocValues`
Returns the number of unique values.

Specified by:
  `getValueCount` in class `SortedSetDocValues`
Returns:
  number of unique values in this SortedDocValues. This is also equivalent to one plus the maximum ordinal.

#### lookupTerm

    public long lookupTerm(BytesRef key)

Description copied from class: `SortedSetDocValues`
If `key` exists, returns its ordinal, else returns `-insertionPoint-1`, like `Arrays.binarySearch`.

Overrides:
  `lookupTerm` in class `SortedSetDocValues`
Parameters:
  `key` - Key to look up