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. Single Insertion ——–

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": {
            "feature": [...]
        }
    }, {
        "field_int": 45085,
        "field_float": 45085,
        "field_double": 45085,
        "field_string": "106085",
        "field_vector": {
            "feature": [...]
        }
    }, {
        "field_int": 52968,
        "field_float": 52968,
        "field_double": 52968,
        "field_string": "113968",
        "field_vector": {
            "feature": [...]
        }
    }]
}
' http://router_server/document/upsert

field_vector is feature 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": {
            "feature": [...]
        }
    }, {
        "_id": "1000001",
        "field_int": 45085,
        "field_float": 45085,
        "field_double": 45085,
        "field_string": "106085",
        "field_vector": {
            "feature": [...]
        }
    }, {
        "_id": "1000002",
        "field_int": 52968,
        "field_float": 52968,
        "field_double": 52968,
        "field_string": "113968",
        "field_vector": {
            "feature": [...]
        }
    }]
}
' http://router_server/document/upsert

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

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

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 cluster/health interface. Complete data for the cluster can be obtained this way.

Find data based on unique id identifier

curl -H "content-type: application/json" -XPOST -d'
{
    "db_name": "ts_db",
    "space_name": "ts_space",
    "query": {
        "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",
    "query": {
        "document_ids": [
        "10000",
        "10001",
        "10002"
        ],
        "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",
    "query": {
        "filter": [
        {
            "range": {
            "field_int": {
                "gte": 1000,
                "lte": 100000
            }
            }
        },
        {
            "term": {
            "field_string": [
                "322"
            ]
            }
        }
        ]
    },
    "vector_value": false
}
' http://router_server/document/query

Query interface return format

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

Parameter Description:

field name

field type

must

remarks

document_ids

json array

false

filter or document_ids must have one

partition_id

json array

false

specify get document on which partition

filter

json array

false

query criteria filtering: numeric filtering + label filtering

fields

json array

false

Specify which fields to return. By default, only the unique id and score are returned.

vector_value

bool

false

default false

size

int

false

Specify the number of returned results, the default is 50

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",
    "query": {
        "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",
    "query": {
        "filter": [
        {
            "range": {
            "field_int": {
                "gte": 1000,
                "lte": 100000
            }
            }
        },
        {
            "term": {
            "field_string": [
                "322"
            ]
            }
        }
        ]
    },
    "size": 3
}
' http://router_server/document/delete

Delete interface return format

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