JSON indexes
JSON indexing is similar to general attribute indexing. Where a general attribute can be indexed several ways and requires a separate database for each index type, with JSON indexing, there is a single database for each JSON field to use for different JSON filter types.
This database primarily behaves like the database for an equality attribute index. Each database entry key is the normalized form for a value for the target JSON field. The corresponding database entry value is a list of the entry IDs for all entries in which the associated attribute type has a JSON object with that value for the target field. The database is configured with a comparator based on the data type for the target field that enables iterating through values in a logical order to facilitate inequality and subInitial searches.
When the JSON field constraint indicates to index a JSON field, JSON indexes are automatically created. Learn more about Configuring JSON attribute constraints.
View indexes with the following command.
$ bin/dbtest list-index-status \
--backendID userRoot \
--baseDN dc=example,dc=com
The JSON object filter types that can be enhanced through the use of JSON indexes include:
equals
-
Identifies entries that have a specific value for the target field. This filter type only requires retrieving a single index key. Depending on the nature of the search filter, the ID list might contain references to entries that do not actually match the filter, such as if the field is a string and if the filter is configured to use case-sensitive matching.
equalsAny
-
Identifies entries that have a specified set of values for the target field. This filter type only requires retrieving the index keys that correspond to the target values in the filter and merging their ID lists.
greaterThan/lessThan
-
Identifies entries that have at least one value for the target field that is greater or less than (or possibly equal to) a specified value. This index is similar in use to the
containsField
index, but it only needs to iterate through a subset of the keys. A filter can contain bothgreaterThan
andlessThan
filters to represent a bounded range. substring
-
Identifies entries that have a string value for the target field that matches a given
substring
. The index can only be used for substring filters that include asubInitial
component. In this case, the server iterates through all of the index keys that match thestartsWith
component and manually compares values against the remainder of the substring assertion.
JSON indexing is available in local database backends backed by Berkeley DB Java Edition. This includes:
-
Add, delete, modify, and modify distinguish name (DN) operations that make changes to JSON objects stored in the server.
-
LDIF imports that include JSON objects, including updates to the cache size estimates for the JSON indexes.
-
The
rebuild-index
tool and corresponding backend code make it possible to generate and rebuild indexes for JSON data. It must be possible to build all JSON indexes for all or a specified subset of fields associated with a given attribute type. Theverify-index
tool also works with JSON indexes to make it possible to check their validity.-
When rebuilding a JSON index with the
rebuild-index
tool, the attribute name must be followed by.json
. Optionally, you can also add.<fieldName>
, where<fieldName>
is replaced by the name of the JSON field.bin/rebuild-index --index <attributeName>.json.<fieldName>
For the exact name to use in rebuilding the index, run the
dbtest
tool with thelist-database-containers
option and--backendID
property.bin/dbtest list-database-containers --backendID {backendID}
-
-
Matching entry count control and
debugsearchindex
return attribute provide information about relevant JSON index usage. -
Support for monitoring index content and usage.
Exploded indexes and the entry balancing global index do not support JSON objects. |