Package org.apache.lucene.facet

# Class LongValueFacetCounts

java.lang.Object
org.apache.lucene.facet.Facets
org.apache.lucene.facet.LongValueFacetCounts

public class LongValueFacetCounts extends Facets
`Facets` implementation that computes counts for all unique long values, more efficiently counting small values (0-1023) using an int array, and switching to a `HashMap` for values above 1023. Retrieve all facet counts, in value order, with `getAllChildrenSortByValue()`, or get all children with no ordering requirements with `getAllChildren(String, String...)`, or get the topN values sorted by count with `getTopChildren(int, String, String...)`.

WARNING: This API is experimental and might change in incompatible ways in the next release.

## Constructor Summary

Constructors
Constructor
Description
`LongValueFacetCounts(String field, FacetsCollector hits)`
Create `LongValueFacetCounts`, using either single-valued `NumericDocValues` or multi-valued `SortedNumericDocValues` from the specified field (depending on what has been indexed).
`LongValueFacetCounts(String field, MultiLongValuesSource valuesSource, FacetsCollector hits)`
Create `LongValueFacetCounts`, using the provided `MultiLongValuesSource` if non-null.
`LongValueFacetCounts(String field, MultiLongValuesSource valuesSource, IndexReader reader)`
Counts all facet values for the provided `MultiLongValuesSource` if non-null.
`LongValueFacetCounts(String field, IndexReader reader)`
Counts all facet values for this reader.
`LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits)`
Create `LongValueFacetCounts`, using the provided `LongValuesSource` if non-null.
`LongValueFacetCounts(String field, LongValuesSource valueSource, IndexReader reader)`
Counts all facet values for the provided `LongValuesSource` if non-null.

## Method Summary

Modifier and Type
Method
Description
`FacetResult`
`getAllChildren(String dim, String... path)`
Returns all child labels with non-zero counts under the specified path.
`FacetResult`
`getAllChildrenSortByValue()`
Returns all unique values seen, sorted by value.
`List<FacetResult>`
`getAllDims(int topN)`
Returns topN labels for any dimension that had hits, sorted by the number of hits that dimension matched; this is used for "sparse" faceting, where many different dimensions were indexed, for example depending on the type of document.
`Number`
`getSpecificValue(String dim, String... path)`
Return the count or value for a specific path.
`FacetResult`
`getTopChildren(int topN, String dim, String... path)`
Returns the topN child labels under the specified path.
`String`
`toString()`

### Methods inherited from class org.apache.lucene.facet.Facets

`getTopDims, validateTopN`

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

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

## Constructor Details

### LongValueFacetCounts

public LongValueFacetCounts(String field, FacetsCollector hits) throws IOException
Create `LongValueFacetCounts`, using either single-valued `NumericDocValues` or multi-valued `SortedNumericDocValues` from the specified field (depending on what has been indexed).

Throws:
  `IOException`

### LongValueFacetCounts

public LongValueFacetCounts(String field, LongValuesSource valueSource, FacetsCollector hits) throws IOException
Create `LongValueFacetCounts`, using the provided `LongValuesSource` if non-null. If `valueSource` is null, doc values from the provided `field` will be used.

Throws:
  `IOException`

### LongValueFacetCounts

public LongValueFacetCounts(String field, MultiLongValuesSource valuesSource, FacetsCollector hits) throws IOException
Create `LongValueFacetCounts`, using the provided `MultiLongValuesSource` if non-null. If `valuesSource` is null, doc values from the provided `field` will be used.

Throws:
  `IOException`

### LongValueFacetCounts

public LongValueFacetCounts(String field, IndexReader reader) throws IOException
Counts all facet values for this reader. This produces the same result as computing facets on a `MatchAllDocsQuery`, but is more efficient.

Throws:
  `IOException`

### LongValueFacetCounts

public LongValueFacetCounts(String field, LongValuesSource valueSource, IndexReader reader) throws IOException
Counts all facet values for the provided `LongValuesSource` if non-null. If `valueSource` is null, doc values from the provided `field` will be used. This produces the same result as computing facets on a `MatchAllDocsQuery`, but is more efficient.

Throws:
  `IOException`

### LongValueFacetCounts

public LongValueFacetCounts(String field, MultiLongValuesSource valuesSource, IndexReader reader) throws IOException
Counts all facet values for the provided `MultiLongValuesSource` if non-null. If `valueSource` is null, doc values from the provided `field` will be used. This produces the same result as computing facets on a `MatchAllDocsQuery`, but is more efficient.

Throws:
  `IOException`

## Method Details

### getAllChildren

public FacetResult getAllChildren(String dim, String... path) throws IOException
Description copied from class: `Facets`
Returns all child labels with non-zero counts under the specified path. Users should make no assumptions about ordering of the children. Returns null if the specified path doesn't exist or if this dimension was never seen.

Specified by:
  `getAllChildren` in class `Facets`
Throws:
  `IOException`

### getTopChildren

public FacetResult getTopChildren(int topN, String dim, String... path)
Description copied from class: `Facets`
Returns the topN child labels under the specified path. Returns null if the specified path doesn't exist or if this dimension was never seen.

Specified by:
  `getTopChildren` in class `Facets`

### getAllChildrenSortByValue

public FacetResult getAllChildrenSortByValue()
Returns all unique values seen, sorted by value. This functionality is very similar to `getAllChildren(String, String...)`, but it guarantees the returned values will be sorted by value (while `#getAllChildren` doesn't guarantee any sort order).

Note: If you don't care about the order of children returned, it may be slightly more efficient to use `getAllChildren(String, String...)`.

### getSpecificValue

public Number getSpecificValue(String dim, String... path)
Description copied from class: `Facets`
Return the count or value for a specific path. Returns -1 if this path doesn't exist, else the count.

Specified by:
  `getSpecificValue` in class `Facets`

### getAllDims

public List<FacetResult> getAllDims(int topN)
Description copied from class: `Facets`
Returns topN labels for any dimension that had hits, sorted by the number of hits that dimension matched; this is used for "sparse" faceting, where many different dimensions were indexed, for example depending on the type of document.

Specified by:
  `getAllDims` in class `Facets`

### toString

public String toString()

Overrides:
  `toString` in class `Object`