all_json_names index parameter

Enable the all_json_names index parameter to index JSON or BSON documents as field name-value pairs instead of as unstructured text.

All the field names in the documents in the column are indexed as fields in the bts index. When you query on the JSON or BSON column, you must specify the field name to search in the bts_contains() search predicate.

You can include the json_path_processing and json_array_processing index parameters to add the paths and array positions to the field names.

To view the fields that you indexed, run the bts_index_fields() function.

Example: Index all field name-value pairs

The following statement creates a bts index with the all_json_names index parameter enabled on the example JSON docs column:

CREATE INDEX bts_idx 
          ON json_tab (docs bts_json_ops) 
       USING bts(all_json_names="yes"); 

The resulting index contains the following field name-value pairs:

givenname: jim
surname: flynn
givenname: slim 
surname: flynn
age: 29
cars: dodge
cars: olds
givenname: lynn 
surname: kim

You can specify the following fields in the search predicate: givenname, surname, age, and cars.