Create Table

This chapter introduces how to create tables in Hippo. The following example creates a table named “book” with one shard and one replica. And table “book” has a primary key called “book_id” using Int64 as the data type, a scalar column called “word_count” using Int64 as the data type and a vector column containing Float numbers with 2 dimensions.

curl -u shiva:shiva -XPUT 'localhost:8902/hippo/v1/{table}?database_name={database_name}&pretty' -H 'Content-Type: application/json' -d'{
  "settings": {
    "number_of_shards" : 1,
    "number_of_replicas" : 1
  },
  "schema": {
    "auto_id": false,
    "fields": [
      {
        "name": "book_id",
        "is_primary_key": true,
        "data_type": "int64"
      },
      {
        "name": "word_count",
        "is_primary_key": false,
        "data_type": "int64"
      },
      {
        "name": "book_intro",
        "data_type": "float_vector",
        "is_primary_key": false,
        "type_params": {
          "dimension" : 2
        }
      }
    ]
  }
}';

Result:

{
  "acknowledged" : true
}

Parameter description:

ParametersDescriptionOptions
tableTable name, such as “book” created in this example
database_nameDatabase name, URL parameter[1, 5]
auto_idIf self-generated ID is enabled. Currently Hippo only enables self-generated ID for schema containing only one String primary keyTrue/False
fields (schema)The fields for the newly created schema in this example
name (field)Field nameN/A
is_primary_keyWhether the column is primary keyTrue/False
data_typeData type for the column
  • Int8
  • Int16
  • Int32
  • Int64
  • Float
  • Double
  • Bool
  • String
  • Char
  • Varchar
  • Varchar2
  • Date
  • Timestamp
  • Datetime
  • Binary
  • Blob
  • Clob
  • Float_vector
  • dimVector dimension[1, 65536]
    lengthLength, varchar/varchar2 data type[1, 65536]
    Table 1 Table Creation and Column Data Types (Restful API)