bts_index_fields() function

The bts_index_fields() function returns the list of indexed field names in the bts index.

Syntax


1  bts_index_fields ( ' index_name ' )
index_name
The name of the bts index.

Usage

Use the bts_index_fields() function to identify searchable fields in the bts index. Optionally, you can include the index storage space path and file name, the database name, and the owner name in addition to the index name, which is separated by forward slash (/) characters.

The bts_index_fields() function returns one default field that is called contents unless any of the following conditions are true:

  • The index is a composite index that has each column that is indexed separately because the index definition includes the query_default_field="*" index parameter. The bts_index_fields() function returns the names of the indexed columns.
  • The index contains XML tags because the index definition includes the all_xmltags or xmltags index parameter. The bts_index_fields() function returns the indexed tags. If the include_contents index parameter is included in the index definition, the bts_index_fields() function also returns the contents field.
  • The index contains JSON field name-value pairs because the index definition includes the all_json_names or json_names index parameter. The bts_index_fields() function returns the indexed field names. If the include_contents index parameter is included in the index definition, the bts_index_fields() function also returns the contents field.

When you specify tags with the xmltags parameter, the bts_index_fields() function returns only field names for tags that exist in the indexed column. However, if later you add a row that contains the specified tag name, the field name for that tag appears in the output.

The bts_index_fields() function returns the field names in alphabetical order.

Example: Unstructured index

The following statement creates an unstructured index:
CREATE INDEX desc_idx ON products (brands  bts_char_ops)
 USING bts IN sbsp1;

The bts_index_fields() function returns the default field: contents.

Examples: Structured indexes on an XML document

These examples are based on the following XML fragment:
<boat>
 <skipper>Captain Jack</skipper>
 <boatname>Black Pearl</boatname>
</boat>
The following statement indexes the specified XML tags:
CREATE INDEX boats_bts ON boats(xml_data bts_lvarchar_ops) 
USING bts(xmltags="(skipper,boatname,crew)") IN bts_sbspace;
The bts_index_fields() function returns the following field names:
boatname 
skipper 

The field name for the tag crew is not returned because it does not exist in the XML fragment example.

The following statement indexes all tags and paths:
CREATE INDEX boats_bts ON boats(xml_data bts_lvarchar_ops) 
USING bts(all_xmltags="yes",xmlpath_processing="yes") 
IN bts_sbspace; 
The bts_index_fields() function returns field names that include full paths:
/boat/boatname
/boat/skipper
The following statement indexes all tags and includes the contents field:
CREATE INDEX boats_bts ON boats(xml_data bts_lvarchar_ops) 
USING bts(all_xmltags="yes",include_contents="yes") 
IN bts_sbspace; 
The bts_index_fields() function returns the following fields:
boatname
contents
skipper

Examples: Structured indexes on a JSON document

These examples are based on the following JSON document:

{ "person" : {
     "givenname" : "Jim", 
     "surname" : "Flynn",
     "age" : 29,
     "cars" : [ "dodge", "olds" ],
     "parents":[ 
        { "givenname" : "Slim",       
          "surname" : "Flynn",            
          "surname" : "Kim" }
     ]
}

The following statement indexes all field name-value pairs:

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

The bts_index_fields() function returns the following fields:

age
cars
givenname
surname

The following statement indexes all field name-value pairs and includes the contents field:

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

The bts_index_fields() function returns the following fields:

age
cars
contents
givenname
surname

The following statement indexes a single field:

CREATE INDEX bts_idx 
          ON json_tab (docs bts_json_ops) 
       USING bts(json_names="surname"); 

The bts_index_fields() function returns the following field:

surname

The following statement indexes the specified field names and paths:

CREATE INDEX bts_idx 
          ON json_tab (docs bts_json_ops) 
       USING bts(
                 json_names="(parents.surname,
                              person.givenname)",
                 json_path_processing="yes"
        ); 

The bts_index_fields() function returns the following fields:

person.given name
parents.surname