Skip to main content

REST - /v1/objects

caution
This section of the documentation is deprecated and will be removed in the future.
Please refer to the OpenAPI documentation for the most up-to-date information.

For client examples, see this section.

List data objects

Do you want to list all objects from Weaviate?

Use the after operator.

List data objects in reverse order of creation. The data will be returned as an array of objects.

After a class object count?

A: This Aggregate query will output a total object count in a class.

import weaviate
import weaviate.classes as wvc
import os

client = weaviate.connect_to_local()

try:
collection = client.collections.get("Article")
response = collection.aggregate.over_all(total_count=True)

print(response.total_count)

finally:
client.close()

Method and URL

Without any restrictions (across classes, default limit = 25):

GET /v1/objects

With optional query params:

GET /v1/objects?class={ClassName}&limit={limit}&include={include}

Parameters

All parameters below are optional URL query parameters
NameTypeDescription
classstringList objects by class using the class name.
limitintegerThe maximum number of data objects to return. Default 25.
offsetintegerThe offset of objects returned (the starting index of the returned objects).

Cannot be used with after.
Should be used in conjunction with limit.
afterstringReturned objects follow the object with this ID. This object is not part of the set.

Must be used with class
Cannot be used with offset or sort.
Should be used in conjunction with limit.
includestringInclude additional information, such as classification info.

Allowed values include: classification, vector, featureProjection and other module-specific additional properties.
sortstringName of the property to sort by - i.e. sort=city

You can also provide multiple names – i.e. sort=country,city
orderstringOrder in which to sort by.

Possible values: asc (default) and desc.
Should be used in conjunction with sort.

Paging: offset

tip

You can use limit and offset for paging results.

The offset parameter is a flexible way to page results as it allows use with parameters such as sort. It is limited by the value of QUERY_MAXIMUM_RESULTS which sets the maximum total number of objects that can be listed using this parameter.

Get the first 10 objects:

GET /v1/objects?class=MyClass&limit=10

Get the second batch of 10 objects:

GET /v1/objects?class=MyClass&limit=10&offset=10

Get the next batch of 10 objects:

GET /v1/objects?class=MyClass&limit=10&offset=20

Exhaustive listing using a cursor: after

tip
  • Available from version v1.18.0.
  • You can use class, limit and after for listing an entire object set from a class.
  • The after operator is based on the order of ids. It can therefore only be applied to list queries without sorting.

You can use the after operator to retrieve all objects from a Weaviate instance . The after operator ("Cursor API") retrieves objects of a class based on the order of ids. You can pass the id of the last retrieved object as a cursor to start the next page.

It is not possible to use the after operator without specifying a class.

For a null value similar to offset=0, set after= or after (i.e. with an empty string) in the request.

Examples

Get the first 10 objects of MyClass:

GET /v1/objects?class=MyClass&limit=10

If the last object in the retrieved set above was b1645a32-0c22-5814-8f35-58f142eadf7e, you can retrieve the next 10 objects of MyClass after it as below:

GET /v1/objects?class=MyClass&limit=10&after=b1645a32-0c22-5814-8f35-58f142eadf7e

Example sorting

tip

You can use sort and order to sort your results.

Ascending sort by author_name:

GET /v1/objects?class=Book&sort=author_name

Descending sort by author_name:

GET /v1/objects?class=Book&sort=author_name&order=desc

Sort by by author_name, and then title.

GET /v1/objects?class=Book&sort=author_name,title

Sort by author_name, and then title with order:

GET /v1/objects?class=Book&sort=author_name,title&order=desc,asc

Response fields

The response of a GET query of a data object will give you information about all objects (or a single object). Next to general information about the data objects, like schema information and property values, meta information will be shown depending on the include fields or additional properties of your request.

Response format

{
"objects": [/* list of objects, see below */],
"deprecations": null,
}

Object fields

Field nameData typeRequired include or additional fieldDescription
classstringnoneThe class name.
creationTimeUnixunix timestampnoneThe time stamp of creation of the data object.
iduuidnoneThe uuid of the data object.
lastUpdateTimeUnixunix timestampnoneThe time stamp when the data object was last updated.
properties > {propertyName}dataTypenoneThe name and value of an individual property.
properties > {crefPropertyName} > classification > closestLosingDistancefloatclassificationThe lowest distance of a neighbor in the losing group. Optional. If k equals the size of the winning group, there is no losing group.
properties > {crefPropertyName} > classification > closestOverallDistancefloatclassificationThe lowest distance of any neighbor, regardless of whether they were in the winning or losing.
properties > {crefPropertyName} > classification > closestWinningDistancefloatclassificationClosest distance of a neighbor from the winning group.
properties > {crefPropertyName} > classification > losingCountintegerclassificationSize of the losing group, can be 0 if the winning group size equals k.
properties > {crefPropertyName} > classification > meanLosingDistancefloatclassificationThe mean distance of the losing group. It is a normalized distance (between 0 and 1), where 0 means equal and 1 would mean a perfect opposite.
properties > {crefPropertyName} > classification > meanWinningDistancefloatclassificationThe mean distance of the winning group. It is a normalized distance (between 0 and 1), where 0 means equal and 1 would mean a perfect opposite.
properties > {crefPropertyName} > classification > overallCountintegerclassificationOverall neighbors checked as part of the classification. In most cases this will equal k, but could be lower than k - for example if not enough data was present.
properties > {crefPropertyName} > classification > winningCountintegerclassificationSize of the winning group, a number between 1 and k.
vectorlist of floatsvectorThe vector embedding computed for the object.
classification > basedOnstringclassificationThe property name where the classification was based on.
classification > classifiedFieldsstringclassificationThe classified property.
classification > completedtimestampclassificationThe time of classification completion.
classification > iduuidclassificationThe classification id.
classification > scopelist of stringsclassificationThe initial fields to classify.
featureProjection > vectorlist of floatsfeatureProjectionThe 2D or 3D vector coordinates of the feature projection.

Status codes and error cases

CauseDescriptionResult
No objects presentNo ?class is provided. There are no objects present in the entire Weaviate instance.200 OK - No error
Valid class, no objects present?class is provided, class exists. There are no objects present for this class.200 OK - No error
Invalid class?class is provided, class does not exist.404 Not Found
ValidationOtherwise invalid user request.422 Unprocessable Entity
AuthorizationNot allowed to view resource.403 Forbidden
Server-Side errorCorrect user input, but request failed for another reason.500 Internal Server Error - contains detailed error message

Example request

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
articles = client.collections.get("Article")
response = articles.query.fetch_objects()

for o in response.objects:
print(o.properties)

finally:
client.close()

Create a data object

Create a new data object. The provided meta-data and schema values are validated.

Method and URL

POST /v1/objects[?consistency_level=ONE|QUORUM|ALL]
note

The class name is not specified in the URL, as it is part of the request body.

Parameters

The URL supports an optional consistency level query parameter:

NameLocationTypeDescription
consistency_levelquery paramstringOptional consistency level: ONE, QUORUM (default) or ALL.

The request body for a new object has the following fields:

NameTypeRequiredDescription
classstringyesThe class name as defined in the schema
propertiesarrayyesAn object with the property values of the new data object
properties > {propertyName}dataTypeyesThe property and its value according to the set dataType
idv4 UUIDnoOptional id for the object
vector[float]noOptional custom vector
tenantstringnoOptional tenant name. Multi-tenancy must be enabled first.

Example request

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
authors = client.collections.get("Author")
obj_uuid = "36ddd591-2dee-4e7e-a3cc-eb86d30a4303"
# articles = articles.with_consistency_level(wvc.config.ConsistencyLevel.ALL) # If you want to set the consistency level

authors.data.insert(
properties={"name": "Jodi Kantor"},
uuid=obj_uuid,
# If you want to add a reference (and configured in the collection definition)
# references={"writesFor": "f81bfe5e-16ba-4615-a516-46c2ae2e5a80"}
)

for o in response.objects:
print(o.properties)

finally:
client.close()

objects vs batch

tip

The objects endpoint is meant for individual object creations.

If you plan on importing a large number of objects, it's much more efficient to use the /v1/batch endpoint. Otherwise, sending multiple single requests sequentially would incur a large performance penalty:

  1. Each sequential request would be handled by a single thread server-side while most of the server resources are idle. In addition, if you only send the second request once the first has been completed, you will wait for a lot of network overhead.
  2. It's much more efficient to parallelize imports. This will minimize the connection overhead and use multiple threads server-side for indexing.
  3. You do not have to do the parallelization yourself, you can use the /v1/batch endpoint for this. Even if you are sending batches from a single client thread, the objects within a batch will be handled by multiple server threads.
  4. Import speeds, especially for large datasets, will drastically improve when using the batching endpoint.
Idempotence of POST requests in objects and batch

The idempotence behavior differs between these two endpoints. POST /batch/objects is idempotent, and will overwrite any existing object given an id. POST /objects will fail if an id is provided which already exists in the class.

To update an existing object with the objects endpoint, use the PUT or PATCH method.

With geoCoordinates

If you want to supply a geoCoordinates property, you need to specify the latitude and longitude as floating point decimal degrees:

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
publications = client.collections.get("Publication")

publications.data.insert(
properties={
"headquartersGeoLocation": {
"latitude": 52.3932696,
"longitude": 4.8374263
}
},
)

finally:
client.close()
Limitations

Currently, geo-coordinate filtering is limited to the nearest 800 results from the source location, which will be further reduced by any other filter conditions and search parameters.

If you plan on a densely populated dataset, consider using another strategy such as geo-hashing into a text datatype, and filtering further, such as with a ContainsAny filter.

With a custom vector

When creating a data object, you can configure Weaviate to generate a vector with a vectorizer module, or you can provide the vector yourself. We sometimes refer to this as a "custom" vector.

You can provide a custom vector during object creation either when:

  • you are not using a vectorizer for that class, or
  • you are using a vectorizer, but you wish to bypass it during the object creation stage.

You can create a data object with a custom vector as follows:

  1. Set the "vectorizer" in the relevant class in the data schema.
    • If you are not using a vectorizer at all, configure the class accordingly. To do this, you can:
      • set the default vectorizer module to "none" (DEFAULT_VECTORIZER_MODULE="none"), or
      • set the "vectorizer" for the class to "none" ("vectorizer": "none") (note: the class vectorizer setting will override the DEFAULT_VECTORIZER_MODULE parameter).
    • If you wish to bypass the vectorizer for object creation:
      • set the vectorizer to the same vectorizer with identical settings used to generate the custom vector

        Note: There is NO validation of this vector besides checking the vector length.

  2. Then, attach the vector in a special "vector" field during object creation. For example, if adding a single object, you can:
# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
authors = client.collections.get("Author")
# authors = authors.with_consistency_level(wvc.config.ConsistencyLevel.ALL) # If you want to set the consistency level

authors.data.insert(
properties={"name": "Custom Vector Author"},
vector=[0.3] * 1536, # If you want to specify a vector
# references=wvc.data.Reference("f81bfe5e-16ba-4615-a516-46c2ae2e5a80"), # If you want to add a reference (if configured in the collection definition)
)

for o in response.objects:
print(o.properties)

finally:
client.close()
note

You can set custom vectors for batch imports as well as single object creation.

See also how to search using custom vectors.

Get a data object

Collect an individual data object.

Method and URL

Available since v1.14 and the preferred way:

GET /v1/objects/{ClassName}/{id}[?consistency_level=ONE|QUORUM|ALL&tenant={tenant}]
Getting a data object without a class name is deprecated

The following syntax is deprecated. It is only available for backward compatibility.

GET /v1/objects/{id}
Collection (class) Name in Object CRUD Operations

Collections act like namespaces, so two different collections could have duplicate IDs between them.


Prior to Weaviate v1.14 you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate v2.0.0.

Starting in v1.20, you can have multi-tenant datasets. When multi-tenancy is enabled, the tenant name is required.

Always include the collection name, and, when enabled, the tenant name.

URL parameters

NameLocationTypeDescription
{ClassName}pathstringThe name of the class that the object belongs to.
{id}query paramuuidThe uuid of the data object to retrieve.
includequery paramstringInclude additional information, such as classification info. Allowed values include: classification, vector.
consistency_levelquery paramstringOptional consistency level: ONE, QUORUM (default) or ALL.
tenantquery paramstringOptional tenant key. Multi-tenancy must be enabled first.

Example request

The response fields are explained in the corresponding section above.

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
object_uuid = generate_uuid5("SomeUUIDSeed")

authors = client.collections.get("Author")
# authors = authors.with_consistency_level(wvc.config.ConsistencyLevel.ALL) # If you want to set the consistency level

fetched_obj = authors.query.fetch_object_by_id(uuid=object_uuid) # If it does not exist, it will return None

if fetched_obj is None:
print("Object does not exist")
else:
print(fetched_obj.properties)

finally:
client.close()

Check if a data object exists

The same endpoint above can be used with the HEAD HTTP method to check if a data object exists without retrieving it. Internally it skips reading the object from disk (other than checking if it is present), thus not using resources on marshalling, parsing, etc. Additionally, the resulting HTTP request has no body; the existence of an object is indicated solely by the status code (204 when the object exists, 404 when it doesn't, 422 on invalid ID).

Method and URL

Available since v1.14 and the preferred way:

HEAD /v1/objects/{ClassName}/{id}[?consistency_level=ONE|QUORUM|ALL]
Checking if a data object exists without a class name is deprecated

The following syntax is deprecated. It is only available for backward compatibility.

HEAD /v1/objects/{id}
Collection (class) Name in Object CRUD Operations

Collections act like namespaces, so two different collections could have duplicate IDs between them.


Prior to Weaviate v1.14 you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate v2.0.0.

Starting in v1.20, you can have multi-tenant datasets. When multi-tenancy is enabled, the tenant name is required.

Always include the collection name, and, when enabled, the tenant name.

URL parameters

NameLocationTypeDescription
{ClassName}pathstringThe name of the class that the object belongs to
{id}pathuuidThe uuid of the data object to retrieve
consistency_levelquery paramstringOptional consistency level: ONE, QUORUM (default) or ALL.
tenantquery paramstringOptional tenant name. Multi-tenancy must be enabled first.

Example request

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
object_uuid = generate_uuid5("SomeUUIDSeed")

authors = client.collections.get("Author")
# authors = authors.with_consistency_level(wvc.config.ConsistencyLevel.ALL) # If you want to set the consistency level

fetched_obj = authors.query.fetch_object_by_id(uuid=object_uuid) # If it does not exist, it will return None

if fetched_obj is None:
print("Object does not exist")
else:
print(fetched_obj.properties)

finally:
client.close()

Update a data object

Update an individual data object based on its uuid.

Method and URL

In the RESTful API, both PUT and PATCH methods are accepted. PUT replaces all property values of the data object, while PATCH only overwrites the given properties.

Available since v1.14 and the preferred way:

PUT /v1/objects/{ClassName}/{id}[?consistency_level=ONE|QUORUM|ALL]
PATCH /v1/objects/{ClassName}/{id}[?consistency_level=ONE|QUORUM|ALL]
Updating a data object without a class name are deprecated

The following syntax is deprecated. It is only available for backward compatibility.

PUT /v1/objects/{id}
PATCH /v1/objects/{id}
Collection (class) Name in Object CRUD Operations

Collections act like namespaces, so two different collections could have duplicate IDs between them.


Prior to Weaviate v1.14 you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate v2.0.0.

Starting in v1.20, you can have multi-tenant datasets. When multi-tenancy is enabled, the tenant name is required.

Always include the collection name, and, when enabled, the tenant name.

Recalculating vectors on update

If the class is configured with a vectorizer, Weaviate will only compute a new vector for an updated object if the update changes the underlying text to be vectorized.

Parameters

The URL has two required path parameters and supports an optional query parameter for the consistency level:

NameLocationTypeDescription
{ClassName}pathstringThe name of the class that the object belongs to
{id}pathuuidThe uuid of the data object to update
consistency_levelquery paramstringOptional consistency level: ONE, QUORUM (default) or ALL.

The request body for replacing (some) properties of an object has the following fields:

NameTypeRequiredDescription
classstringyesThe class name as defined in the schema
idstring?Required for PUT to be the same id as the one passed in the URL
propertiesarrayyesAn object with the property values of the new data object
properties > {propertyName}dataTypeyesThe property and its value according to the set dataType
vector[float]noOptional custom vector
tenantstringnoOptional tenant name. Multi-tenancy must be enabled first.

Example request

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
object_uuid = generate_uuid5("SomeUUIDSeed")

actors = client.collections.get("Actor")
# actors = actors.with_consistency_level(wvc.config.ConsistencyLevel.ALL) # If you want to set the consistency level

# ===== Insert the original object =====
actors.data.insert(
properties={
"first_name": "Gary",
"last_name": "Oldman",
},
vector=[0.3] * 1536, # If you want to specify a vector
uuid=object_uuid,
)

# ===== To update an object =====
actors.data.update(
uuid=object_uuid,
vector=[0.4] * 1536, # If you want to specify a vector
properties={"first_name": "Randy"}, # Only the first name will be updated
)

# ===== To replace an object =====
actors.data.replace( # This will replace the entire object
uuid=object_uuid,
vector=[0.5] * 1536, # If you want to specify a vector
properties={
"first_name": "Randy",
"last_name": "Newman",
},
)

finally:
client.close()

If the update was successful, no content will be returned.

Delete a data object

Delete an individual data object from Weaviate.

Method and URL

Available since v1.14 and preferred way:

DELETE /v1/objects/{ClassName}/{id}[?consistency_level=ONE|QUORUM|ALL]
Deleting a data object without a class name is deprecated

The following syntax is deprecated. It is only available for backward compatibility.

DELETE /v1/objects/{id}
Collection (class) Name in Object CRUD Operations

Collections act like namespaces, so two different collections could have duplicate IDs between them.


Prior to Weaviate v1.14 you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate v2.0.0.

Starting in v1.20, you can have multi-tenant datasets. When multi-tenancy is enabled, the tenant name is required.

Always include the collection name, and, when enabled, the tenant name.

URL parameters

NameLocationTypeDescription
{ClassName}pathstringThe name of the class that the object belongs to
{id}pathuuidThe uuid of the data object to delete
consistency_levelquery paramstringOptional consistency level: ONE, QUORUM (default) or ALL.
tenantquery paramstringOptional tenant name. Multi-tenancy must be enabled first.

Example request

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
actors = client.collections.get("Actor")
# actors = actors.with_consistency_level(wvc.config.ConsistencyLevel.ALL) # If you want to set the consistency level

object_uuid = generate_uuid5("SomeUUIDSeed")

actors.data.delete_by_id(object_uuid)

finally:
client.close()

If the deletion was successful, no content will be returned.

Validate a data object

You can validate an object's schema and metadata without creating it. If the schema of the object is valid, the request should return True/true in case of the clients, and nothing with a plain RESTful request. Otherwise, an error object will be returned.

Method and URL

POST /v1/objects/validate
note

As with creating an object, the class name is not specified through the URL, as it is part of the request body.

Parameters

The request body for validating an object has the following fields:

NameTypeRequiredDescription
classstringyesThe class name as defined in the schema
propertiesarrayyesAn object with the property values of the new data object
properties > {propertyName}dataTypeyesThe property and its value according to the set dataType
idv4 uuidno*The id of the data object.
*An ID is required by the clients.

Example request

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
# Coming soon

finally:
client.close()

Cross-references

Cross-references are object properties for establishing links from the source object to another object via a beacon.

Cross-references do not affect vectors

Creating cross-references does not affect object vectors in either direction.

Add a cross-reference

POST request that adds a reference to the array of cross-references of the given property in the source object specified by its class name and id.

Method and URL

Available since v1.14 and the preferred way:

POST /v1/objects/{ClassName}/{id}/references/{propertyName}[?consistency_level=ONE|QUORUM|ALL]
Adding a cross-reference without a class name is deprecated

The following syntax is deprecated. It is only available for backward compatibility.

POST /v1/objects/{id}/references/{propertyName}
Collection (class) Name in Object CRUD Operations

Collections act like namespaces, so two different collections could have duplicate IDs between them.


Prior to Weaviate v1.14 you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate v2.0.0.

Starting in v1.20, you can have multi-tenant datasets. When multi-tenancy is enabled, the tenant name is required.

Always include the collection name, and, when enabled, the tenant name.

Parameters

The URL includes three required path parameters and supports an optional query parameter for the consistency level:

NameLocationTypeDescription
{ClassName}pathstringThe name of the class that the object belongs to, e.g. Article
{id}pathuuidThe uuid of the object to add the reference to
{propertyName}pathstringThe name of the cross-reference property, e.g. author
consistency_levelquery paramstringOptional consistency level: ONE, QUORUM (default) or ALL.
tenantquery paramstringOptional tenant name. Multi-tenancy must be enabled first.

The request body is an object with the following field:

NameTypeRequiredDescription
beaconWeaviate BeaconyesThe beacon URL of the reference, in the format weaviate://localhost/<ClassName>/<id>
note

For backward compatibility, you can omit the class name in the beacon format and specify it as weaviate://localhost/<id>. This is, however, considered deprecated and will be removed with a future release, as duplicate IDs across classes could mean that this beacon is not uniquely identifiable.

Example request

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
authors = client.collections.get("Author")
# authors = authors.with_consistency_level(wvc.config.ConsistencyLevel.ALL) # If you want to set the consistency level

authors.data.reference_add(
from_uuid=author_uuid,
from_property="writesFor",
to=pub_uuid,
)

finally:
client.close()

If the addition was successful, no content will be returned.

Update a cross-reference

PUT request that updates all references in a specified property of an object specified by its class name and id.

Method and URL

Available since v1.14 and the preferred way:

PUT /v1/objects/{ClassName}/{id}/references/{propertyName}[?consistency_level=ONE|QUORUM|ALL]
Updating a cross-reference without a class name is deprecated

The following syntax is deprecated. It is only available for backward compatibility.

PUT /v1/objects/{id}/references/{propertyName}
Collection (class) Name in Object CRUD Operations

Collections act like namespaces, so two different collections could have duplicate IDs between them.


Prior to Weaviate v1.14 you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate v2.0.0.

Starting in v1.20, you can have multi-tenant datasets. When multi-tenancy is enabled, the tenant name is required.

Always include the collection name, and, when enabled, the tenant name.

Parameters

The URL includes three required path parameters and supports an optional query parameter for the consistency level:

NameLocationTypeDescription
{ClassName}pathstringThe name of the class that the object belongs to
{id}pathuuidThe uuid of the object to update the reference(s) of
{propertyName}pathstringThe name of the cross-reference property
consistency_levelquery paramstringOptional consistency level: ONE, QUORUM (default) or ALL.
tenantquery paramstringOptional tenant name. Multi-tenancy must be enabled first.

The PUT request body is a list of beacons:

NameTypeRequiredDescription
beaconWeaviate Beacon arrayyesArray of beacons in the format weaviate://localhost/<ClassName>/<id>
note

For backward compatibility, you can omit the class name in the beacon format and specify it as weaviate://localhost/<id>. This is, however, considered deprecated and will be removed with a future release, as duplicate IDs across classes could mean that this beacon is not uniquely identifiable.

Example request

# Note - The V4 Python client uses gRPC for object-related operations.
# The snippets shown are for the same functionality as the REST call.

import weaviate

client = weaviate.connect_to_local()

try:
authors = client.collections.get("Author")
# authors = authors.with_consistency_level(wvc.config.ConsistencyLevel.ALL) # If you want to set the consistency level

authors.data.reference_replace(
from_uuid=author_uuid,
from_property="writesFor",
to=new_uuids, # Replace all references attached to the author_uuid
)

finally:
client.close()

If the update was successful, no content will be returned.

Delete a cross-reference

Delete the single reference that is given in the body from the list of references that the specified property of a given object has, if it exists in the list. Returns 204 No Content either way.

Method and URL

Available since v1.14 and the preferred way:

DELETE /v1/objects/{ClassName}/{id}/references/{propertyName}[?consistency_level=ONE|QUORUM|ALL]
Deleting a cross-reference without a class name is deprecated

The following syntax is deprecated. It is only available for backward compatibility.

DELETE /v1/objects/{id}/references/{propertyName}
Collection (class) Name in Object CRUD Operations

Collections act like namespaces, so two different collections could have duplicate IDs between them.


Prior to Weaviate v1.14 you can manipulate objects without specifying the collection name. This method is deprecated. It will be removed in Weaviate v2.0.0.

Starting in v1.20, you can have multi-tenant datasets. When multi-tenancy is enabled, the tenant name is required.

Always include the collection name, and, when enabled, the tenant name.

Parameters

The URL includes two required path parameters and supports an optional query parameter for the consistency level:

NameLocationTypeDescription
{id}pathuuidThe uuid of the object to delete the reference from
{propertyName}pathstringThe name of the cross-reference property
consistency_levelquery paramstringOptional consistency level: ONE, QUORUM (default) or ALL.
tenantquery paramstringOptional tenant name. Multi-tenancy must be enabled first.

The request body is a beacon object:

NameTypeRequiredDescription
beaconWeaviate BeaconyesThe beacon URL of the reference, formatted as weaviate://localhost/<ClassName>/<id>
note

For backward compatibility, beacons generally support an older, deprecated format without the class name, as well. This means you might find beacons with the old, deprecated format, as well as beacons with the new format in the same Weaviate instance. When deleting a reference, the beacon specified has to match the beacon to be deleted exactly. In other words, if a beacon is present using the old format (without class id) you also need to specify it the same way.

Example request

import weaviate

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

client.data_object.reference.delete(
"36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
"wroteArticles",
"6bb06a43-e7f0-393e-9ecf-3c0f4e129064"
from_class_name="SourceClass",
to_class_name="TargetClass",
consistency_level=weaviate.data.replication.ConsistencyLevel.ALL, # default QUORUM
)

If the addition was successful, no content will be returned.

Multi-tenancy

When using multi-tenancy, cross-references can only be made:

  • From a multi-tenancy object to a non-multi-tenancy object.
  • From a multi-tenancy object to a multi-tenancy object, as long as they belong to the same tenant.

Notes

caution

In the beacon format, you need to always use localhost as the host, rather than the actual hostname. localhost refers to the fact that the beacon's target is on the same Weaviate instance, as opposed to a foreign instance.

Questions and feedback

If you have any questions or feedback, let us know in our user forum.