Product Documentation

FairCom DB API for C

Previous Topic

Next Topic

ctdbAddJSONSegment

Add a new index segment on a JSON field.

Declaration

CTHANDLE ctdbAddJSONSegment(CTHANDLE Handle, CTHANDLE FieldHandle, pTEXT key, CTDBTYPE type, VRLEN size);

Description

  • Handle [IN] - Index handle
  • FieldHandle [IN] - Index segment field handle (JSON field)
  • key [IN] - JSON key name that is being indexed
  • type [IN] - c-tree data type of key value
  • size [IN] - key segment length

Returns

Return the segment handle on success or NULL on failure.

Limitations to JSON Key Segments

  1. A CT_JSON key segment does not support the DSCSEG, ALTSEG, or ENDSEG key segment modes. Attempting to create an index that contains a CT_JSON key segment that includes any of these key segment modes fails with error NSUP_ERR.
  2. CT_JSON key segments that use CT_STRING as the c-tree data type are always padded with null (0x0) bytes. We don't support setting a different key segment padding character on JSON key segments.
  3. A CT_JSON key segment can specify any of the following c-tree data types: CT_BOOL, CT_CHAR, CT_CHARU, CT_INT2, CT_INT2U, CT_INT4, CT_INT4U, CT_INT8, CT_DFLOAT, CT_STRING. Note that CT_INT8U is not supported, because JSON only supports a signed 8-byte integer data type.
  4. Remember that the JSON field indexing behaves as follows: if the JSON data type of the value that is being indexed is not compatible with the underlying c-tree data type specified in the key segment definition, that value is treated as NULL and is not indexed. Some examples:
    • If the value is a string and the c-tree data type is an integer, the value is not indexed.
    • If the value is an integer and the c-tree data type is CT_INT2 but the value is out of range for a signed two-byte integer, the value is not indexed.

TOCIndex