Doc Opeartion

http://router_server represents the router service, $db_name is the created library name, $space_name is the created space name, and $id is the unique id of the data record.

_id is the unique identifier of the record generated by the server, which can be specified by the user. This unique identifier needs to be used to modify and delete data.

$id is a unique identifier generated by the server using the specified value when inserting data. The $id value cannot use special characters such as URL paths. If the record with the unique identifier already exists in the library, it will be updated and overwritten.

document/upsert

If primary_id is set, the specified primary key will be used. If not set, generated by Vearch.

If the _id specified when inserting already exists, the existing data is updated; otherwise, it is inserted.

When the documents in the inserted data contain multiple pieces of data, it is a batch insertion. It is generally recommended that the number of batch insertions does not exceed 100 pieces.

Insertion and update now support passing in the values of only some fields. When inserting and only passing in some fields, the vector field must be included. There is no such restriction when updating.

Do not specify unique identification id when inserting

curl -H "content-type: application/json" -XPOST -d'
{
    "db_name": "ts_db",
    "space_name": "ts_space",
    "documents": [{
        "field_int": 90399,
        "field_float": 90399,
        "field_double": 90399,
        "field_string": "111399",
        "field_vector": [...]
    }, {
        "field_int": 45085,
        "field_float": 45085,
        "field_double": 45085,
        "field_string": "106085",
        "field_vector":  [...]
    }, {
        "field_int": 52968,
        "field_float": 52968,
        "field_double": 52968,
        "field_string": "113968",
        "field_vector":  [...]
    }]
}
' http://router_server/document/upsert

field_vector is vector field. All field names, value types, and table structures are consistent

Specify unique identifier when inserting

curl -H "content-type: application/json" -XPOST -d'
{
    "db_name": "ts_db",
    "space_name": "ts_space",
    "documents": [{
        "_id": "1000000",
        "field_int": 90399,
        "field_float": 90399,
        "field_double": 90399,
        "field_string": "111399",
        "field_vector":  [...]
    }, {
        "_id": "1000001",
        "field_int": 45085,
        "field_float": 45085,
        "field_double": 45085,
        "field_string": "106085",
        "field_vector": [...]
    }, {
        "_id": "1000002",
        "field_int": 52968,
        "field_float": 52968,
        "field_double": 52968,
        "field_string": "113968",
        "field_vector": [...]
    }]
}
' http://router_server/document/upsert

The format of the return value of the upsert interface is as follows

{
    "code": 0,
    "msg": "success",
    "data": {
        "total": 3,
        "document_ids": [
            {
                "_id": "-526059949411103803"
            },
            {
                "_id": "1287805132970120733"
            },
            {
                "_id": "-1948185285365684656"
            }
        ]
    }
}

total identifies the number of successful insertions, and document_ids returns the generated _id and insertion result information.

document/query

The /document/query interface is used to accurately search for data that exactly matches the query conditions. The search does not include vector data.

Two methods are supported: one is to obtain documents directly through primary keys, and the other is to obtain corresponding documents based on filter conditions.

If partition_id is set, get the corresponding document on the specified data partition. At this time, the meaning of document_id is the document number on the partition. document_id can be [0, max_docid] of the specified partition, and max_docid and partition information can be obtained through the http://master_server/dbs/$db_name/spaces/$space_name interface. Complete data for the cluster can be obtained this way.

query Parameter Description:

field name

field type

must

remarks

document_ids

string array

Query conditions, filter and document_ids must contain one item

partition_id

int

Specify which partition to obtain data from, used in combination with document_ids

filters

json

Query condition filtering: numerical filtering + label filtering, filter and document_ids must contain one item

fields

string array

Specify which fields to return. By default, all fields except vector fields are returned.

vector_value

bool

Defaults to false, whether to return a vector

limit

int

Specify the number of returned results, the default is 50

  • filters json format description:

"filters": [
    "operator": "AND",
    "conditions": [
        {
            "field": "field_int",
            "operator": ">=",
            "value": 1
        },
        {
            "field": "field_int",
            "operator": "<=",
            "value": 3
        },
        {
            "field": "field_string",
            "operator": "IN",
            "value": ["aaa", "bbb"]
        }
    ]
]

filters format description:

field name

field type

must

remarks

operator

string

true

only support AND now

conditions

json array

true

  1. Filter conditions support multiple conditions, and there is an intersection relationship between multiple conditions, that is, the outermost operator currently supports AND.

conditions format description:

field name

field type

must

remarks

field

string

true

operator

string

true

support >, >=, <, <=, IN

value

json

true

(2) conditions specific filtering conditions, currently supports two types of field type filtering, numeric type and string type (including string array type) Numeric type operators: >, >=, <, <=; String operator type IN

Find data based on unique id identifier

curl -H "content-type: application/json" -XPOST -d'
{
    "db_name": "ts_db",
    "space_name": "ts_space",
    "document_ids": ["6560995651113580768", "-5621139761924822824", "-104688682735192253"]
    "vector_value": true
}
' http://router_server/document/query

Get the corresponding document on the specified data partition. At this time, document_id can be [0, max_docid] of the specified partition.

curl -H "content-type: application/json" -XPOST -d'
{
    "db_name": "ts_db",
    "space_name": "ts_space",
    "document_ids": ["0", "1", "2"],
    "partition_id": "1",
    "vector_value": true
}
' http://router_server/document/query

Find based on Filter expression of custom scalar field

curl -H "content-type: application/json" -XPOST -d'
{
    "db_name": "ts_db",
    "space_name": "ts_space",
    "filters": [
        "operator": "AND",
        "conditions": [
            {
                "field": "field_int",
                "operator": >=,
                "value": 1
            },
            {
                "field": "field_int",
                "operator": <=,
                "value": 3
            }
        ]
    ]
}
' http://router_server/document/query

Query interface return format

{
    "code": 0,
    "msg": "success",
    "data": {
        "total": 3,
        "documents": [{
            "_id": "6560995651113580768",
            "field_double": 202558,
            "field_float": 102558,
            "field_int": 1558,
            "field_string": "1558"
        }, {
            "_id": "-5621139761924822824",
            "field_double": 210887,
            "field_float": 110887,
            "field_int": 89887,
            "field_string": "89887"
        }, {
            "_id": "-104688682735192253",
            "field_double": 207588,
            "field_float": 107588,
            "field_int": 46588,
            "field_string": "46588"
        }]
    }
}

document/delete

Deletion supports two methods: specifying document_ids and filtering conditions.

Delete specified document_ids

curl -H "content-type: application/json" -XPOST -d'
{
    "db_name": "ts_db",
    "space_name": "ts_space",
    "document_ids": ["4501743250723073467", "616335952940335471", "-2422965400649882823"]
}
' http://router_server/document/delete

Delete documents that meet the filter conditions. size specifies the number of items to delete for each data fragment.

curl -H "content-type: application/json" -XPOST -d'
{
    "db_name": "ts_db",
    "space_name": "ts_space",
    "filters": [
        "operator": "AND",
        "conditions": [
            {
                "field": "field_int",
                "operator": >=,
                "value": 1
            },
            {
                "field": "field_int",
                "operator": <=,
                "value": 3
            }
        ]
    ]
    "limit": 3
}
' http://router_server/document/delete

Delete interface return format

{
    "code": 0,
    "msg": "success",
    "data": {
        "total": 3,
        "document_ids": ["4501743250723073467", "616335952940335471", "-2422965400649882823"]
    }
}