Skip to main content

Overview

The Composite JSON index is an enhanced version of the JSON index. It indexes flattened JSON records and can add specialized per-path indexes for common JSON_MATCH predicates.
The Composite JSON index is available from StarTree version 0.11.0. Compact doc ID mapping and the related JSON_MATCH query-path performance improvements are available after the StarTree 0.15 release.
Use the Composite JSON index when you need to query nested JSON paths with one or more of the following patterns:
  • Equality, IN, NOT IN, IS NULL, or IS NOT NULL filters on selected JSON paths.
  • Range filters on numeric JSON fields.
  • Text search with TEXT_MATCH on selected JSON paths.
  • Regex or prefix-style filters with REGEXP_LIKE on selected paths accelerated by an FST index.
  • Count filters over the number of matching flattened records in a JSON document.
The Composite JSON index can also reduce index size by limiting the paths included in the inverted index, disabling array-position indexing, and, for eligible array-free columns, storing a compact doc ID mapping.
Creating both a JSON index and a Composite JSON index on the same column is not recommended. When evaluating JSON_MATCH, Pinot checks for the regular JSON index first and ignores the Composite JSON index.

Configure the Index

Add the Composite JSON index under the column’s fieldConfigList[].indexes entry.
To index every path in the inverted index, use includeAllPaths:

Configuration Parameters

The Composite JSON index supports the JSON index options maxLevels, excludeArray, disableCrossArrayUnnest, includePaths, excludePaths, excludeFields, indexPaths, maxValueLength, and skipInvalidJson. It also supports these Composite JSON options:

Range Indexes

Use rangeIndexConfigs for JSON paths that appear in range predicates.
Range index fields: The range index has one value for each flattened record. If a value is missing or unparseable, Pinot uses the configured defaultValue, or the type default when defaultValue is omitted. This can affect unbounded range queries. For example, if the default value is 0, this query can include documents without $.value:

Text Indexes

Use textIndexConfigs for JSON paths queried with TEXT_MATCH.
The name must be unique. Text index configs also accept the same fields supported by a regular text index, including:
For more information, see the text index documentation.

FST Indexes

FST indexes within Composite JSON were added in StarTree 0.12.
Use fstIndexConfigs to accelerate REGEXP_LIKE predicates on selected JSON paths.
FST indexes require the path to also be available in the Composite JSON inverted index. FST acceleration is not used when invertedIndexPartitionCount is greater than 1; queries fall back to dictionary scanning.

Compact Doc ID Mapping

Compact doc ID mapping is available after the StarTree 0.15 release.
Composite JSON indexes store matches over flattened JSON records and then translate them back to table document IDs. Historically, each immutable segment stored a full (numDocs + 1) * 4 byte int[] mapping for this translation, even when the JSON column was array-free and each document produced at most one flattened record. For array-free columns, the mapping can dominate index size and query latency. On an 11.3M-row segment with about 8% empty JSON documents, the full mapping was about 45 MB. With compact doc ID mapping, the same shape can store a small null-docs bitmap instead, around 125 KB in that measured case. Enable compact mapping with enableCompactDocIdMapping:
enableCompactDocIdMapping writes a newer Composite JSON on-disk format for eligible segments. Keep it disabled during rolling upgrades. Enable it only after every server, peer-download path, and validation path that may read the index has been upgraded to a version that supports compact Composite JSON doc ID mappings.

Eligibility

The flag allows compact mapping, but the index creator still chooses the smallest safe representation for each new immutable segment. With enableCompactDocIdMapping omitted or set to false, all new segments keep the legacy full int[] mapping.

Rollout and Rollback

enableCompactDocIdMapping is read only while creating new immutable segments. Changing the setting does not rewrite existing segments by itself. Use this rollout order:
  1. Upgrade every component that may read Composite JSON indexes.
  2. Set enableCompactDocIdMapping: true on the target column.
  3. Rebuild, refresh, or re-commit the affected segments so new segments are written with the compact representation when eligible.
To roll back to a version that does not support compact mappings:
  1. Set enableCompactDocIdMapping: false.
  2. Refresh or re-commit any affected compact segments so they are written with the legacy mapping.
  3. Downgrade only after no compact-mapping segments remain.

Query Examples

Equality

Range Query

Regex Search with FST

Count Filter

Use the optional third argument to filter by the number of matching flattened records per document.
For IS NULL, a count filter can distinguish empty JSON documents from present documents where the path is absent:

Array Position Indexing

Queries that specify a concrete array position require enablePositionalIndexing: true, even when the same path is also range-indexed.
When enablePositionalIndexing is false, use wildcard paths such as $.grades[*].value instead.

Range Queries on Real-Time Tables

For committed immutable segments, range predicates can use the internal Composite JSON range index. Mutable consuming segments rely on the inverted index path. When you use Composite JSON range predicates on a real-time or hybrid table, include the same JSON path in invertedIndexConfigs. Otherwise, mutable consuming segments can return no rows for that predicate until they commit.

Performance Notes

The following comparisons were measured on internal Composite JSON benchmarks for the improvements available after the StarTree 0.15 release. Recent Composite JSON query-path improvements also avoid cloning read-only postings for compact identity segments and speed up the legacy remap path for array and full-mapping segments. Those improvements require no table-config changes.