Custom Feature Vector Database Structure

The database structure is set via the tnt-schema.lua file.

The structure is created as a set of spaces and fields. Each field is described with the following parameters:

  • id: field id;

  • name: field name, must be the same as the name of a relevant object parameter;

  • field_type: data type (unsigned|string|set[string]|set[unsigned]);

  • default: field default value. If a default value exceeds 1e14 1, use a string data type to specify it, for example, "123123.." instead of 123123...

The following service fields for objects (faces/bodies) in the database are required for correct operation of sf-api.

meta_scheme  = {
  {
      id = 1,
      name = 'feat',
      field_type = 'string',
      default = ""
  },
  {
      id = 2,
      name = 'normalized_id',
      field_type = 'string',
      default = ""
  },
  ...
}

If you need to use metadata, the meta fields must be defined in the tntapi configuration file. So the data schema should be as follows:

cfg_spaces = {
  default = {
    meta_scheme = {
      {
        id = 1,
        name = 'feat',
        field_type = 'string',
        default = ""
      },
     {
        id = 2,
        name = 'normalized_id',
        field_type = 'string',
        default = ""
      },
      {
        id = 3,
        name = 'timestamp',
        field_type = 'unsigned',
        default = 0
      },
      {
        id = 4,
        name = 'photo_hash',
        field_type = 'string',
        default = ""
      },
      {
        id = 5,
        name = 'cam_id',
        field_type = 'string',
        default = ""
      },
      {
        id = 6,
        name = 'person_id',
        field_type = 'unsigned',
        default = 0
      },
      {
        id = 7,
        name = 'tags',
        field_type = 'set[string]',
        default = {}
      }
    },
    meta_indexes = {'cam_id', 'person_id'}
  },
  altscheme = {
    meta_scheme = {
      {
        id = 1,
        name = 'feat',
        field_type = 'string',
        default = ""
      },
      {
        id = 2,
        name = 'normalized_id',
        field_type = 'string',
        default = ""
      },
      {
        id = 3,
        name = 'name',
        field_type = 'string',
        default = ""
      }
    },
    meta_indexes = {}
  }
}