Table of documentation contents

/v1/batching

With batching you can upload a lot of data objects in bulk. This saves time compared to a lot of single request.

Batching Things or Actions

For batching Things or Actions in bulk.

Method and URL

POST /v1/batching/{semantic_kind}

Parameters

namelocationtypedescription
{semantic_kind}URLstringA semantic kind is used to -respectively- describe nouns or verbs. Options are things or actions

The body of the data object for a new Thing or Action takes the following fields:

nametyperequireddescription
semantic_kindlist of data objectsyesthings or actions with a list of data objects, which correspond to the data object body

Example request

  import weaviate

client = weaviate.Client("http://localhost:8080")

first_thing_props = {
    "name": "Jane Doe",
    "writesFor": [{
        "beacon": "weaviate://localhost/things/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
    }]
}
second_thing_props = {
    "name": "John Doe",
    "writesFor": [{
        "beacon": "weaviate://localhost/things/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
    }]
}

batch = weaviate.ThingsBatchRequest()
batch.add_thing(first_thing_props, "Author", "36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
batch.add_thing(second_thing_props, "Author", "36ddd591-2dee-4e7e-a3cc-eb86d30a4304")
client.batch.create_things(batch)

# for adding actions use: 
# batch = weaviate.ActionsBatchRequest()
# batch.add_thing(property_object, class_name, optional_uuid)
# client.batch.create_things(batch)

Example response

[
    {
        "class": "Author",
        "creationTimeUnix": 1599815986651,
        "id": "36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
        "meta": {
            "interpretation": {
                "source": [
                    {
                        "concept": "author",
                        "occurrence": 20912603,
                        "weight": 0.10000000149011612
                    },
                    {
                        "concept": "jane",
                        "occurrence": 4776095,
                        "weight": 0.2752183973789215
                    },
                    {
                        "concept": "doe",
                        "occurrence": 915642,
                        "weight": 0.47120401263237
                    }
                ]
            }
        },
        "schema": {
            "name": "Jane Doe",
            "writesFor": [
                {
                    "beacon": "weaviate://localhost/things/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
                }
            ]
        },
        "deprecations": null,
        "result": {}
    },
    {
        "class": "Author",
        "creationTimeUnix": 1599815986664,
        "id": "36ddd591-2dee-4e7e-a3cc-eb86d30a4304",
        "meta": {
            "interpretation": {
                "source": [
                    {
                        "concept": "author",
                        "occurrence": 20912603,
                        "weight": 0.17070640623569489
                    },
                    {
                        "concept": "john",
                        "occurrence": 38787579,
                        "weight": 0.10000000149011612
                    },
                    {
                        "concept": "doe",
                        "occurrence": 915642,
                        "weight": 0.5287871360778809
                    }
                ]
            }
        },
        "schema": {
            "name": "John Doe",
            "writesFor": [
                {
                    "beacon": "weaviate://localhost/things/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
                }
            ]
        },
        "deprecations": null,
        "result": {}
    }
]

Batching references

For batching cross-references between data objects in bulk.

Method and URL

POST /v1/batching/references

Parameters

The body of the data object for a new Thing or Action is a list of objects containing:

nametyperequireddescription
frombeaconyesThe beacon, in the form of weaviate://{host}/{semantic_kind}/{Classname}/{id}/{cref_property_name}
tobeaconyesThe beacon, in the form of weaviate://{host}/{semantic_kind}/{Classname}/{id}

Example request

  import weaviate
from weaviate import SEMANTIC_TYPE_THINGS, SEMANTIC_TYPE_ACTIONS

client = weaviate.Client("http://localhost:8080")

batch = weaviate.ReferenceBatchRequest()

# Format:
# batch.add_reference(<from_entity_uuid>, <from_class_name>, <from_property_name>, <to_entity_uuid>, <from_semantic_type>, <to_semantic_type>)

batch.add_reference("36ddd591-2dee-4e7e-a3cc-eb86d30a4303", "Author", "wroteArticles", "6bb06a43-e7f0-393e-9ecf-3c0f4e129064", from_semantic_type=SEMANTIC_TYPE_THINGS, to_semantic_type=SEMANTIC_TYPE_THINGS)
batch.add_reference("36ddd591-2dee-4e7e-a3cc-eb86d30a4303", "Author", "wroteArticles", "b72912b9-e5d7-304e-a654-66dc63c55b32", from_semantic_type=SEMANTIC_TYPE_THINGS, to_semantic_type=SEMANTIC_TYPE_THINGS)
batch.add_reference("36ddd591-2dee-4e7e-a3cc-eb86d30a4304", "Author", "wroteArticles", "b72912b9-e5d7-304e-a654-66dc63c55b32", from_semantic_type=SEMANTIC_TYPE_THINGS, to_semantic_type=SEMANTIC_TYPE_THINGS)

body = batch.get_request_body()
client.batch.add_references(batch)

Example response

[
    {
        "from": "weaviate://localhost/things/Author/36ddd591-2dee-4e7e-a3cc-eb86d30a4303/wroteArticles",
        "to": "weaviate://localhost/things/6bb06a43-e7f0-393e-9ecf-3c0f4e129064",
        "result": {
            "status": "SUCCESS"
        }
    },
    {
        "from": "weaviate://localhost/things/Author/36ddd591-2dee-4e7e-a3cc-eb86d30a4303/wroteArticles",
        "to": "weaviate://localhost/things/b72912b9-e5d7-304e-a654-66dc63c55b32",
        "result": {
            "status": "SUCCESS"
        }
    },
    {
        "from": "weaviate://localhost/things/Author/36ddd591-2dee-4e7e-a3cc-eb86d30a4304/wroteArticles",
        "to": "weaviate://localhost/things/b72912b9-e5d7-304e-a654-66dc63c55b32",
        "result": {
            "status": "SUCCESS"
        }
    }
]
Tags
  • RESTful API
  • references
  • batching