List all data objects
Lists all data objects in reverse order of creation. The data will be returned as an array of objects
Method and URL
GET /v1/objects
Parameters
name | location | type | description |
---|---|---|---|
limit | URL | integer | The maximum number of data objects to return, should be 25 or lower. If you want to retrieve more objects, we recommend using GraphQL. |
include | URL | string | Include additional information, such as classification info. Allowed values include: classification , vector , featureProjection and other module-specific additional properties. |
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.
field name | datatype | required include or additional field | description |
---|---|---|---|
class | string | none | the class name |
creationTimeUnix | unix timestamp | none | the time stamp of creation of the data object |
id | uuid | none | the uuid of the data object |
lastUpdateTimeUnix | unix timestamp | none | the time stamp when the data object was last updated |
properties > {property_name} | dataType | none | the name and value of an individual property |
properties > {cref_property_name} > classification > closestLosingDistance | float | classification | The lowest distance of a neighbor in the losing group. Optional. If k equals the size of the winning group, there is no losing group. See for more info here. |
properties > {cref_property_name} > classification > closestOverallDistance | float | classification | The lowest distance of any neighbor, regardless of whether they were in the winning or losing. See for more info here. |
properties > {cref_property_name} > classification > closestWinningDistance | float | classification | Closest distance of a neighbor from the winning group. See for more info here. |
properties > {cref_property_name} > classification > losingCount | integer | classification | Size of the losing group, can be 0 if the winning group size equals k . See for more info here. |
properties > {cref_property_name} > classification > meanLosingDistance | float | classification | The 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. See for more info here. |
properties > {cref_property_name} > classification > meanWinningDistance | float | classification | The 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. See for more info here. |
properties > {cref_property_name} > classification > overallCount | integer | classification | Overall 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. See for more info here. |
properties > {cref_property_name} > classification > winningCount | integer | classification | Size of the winning group, a number between 1 and k . See for more info here. |
vector | list of floats | vector | the long vector of the location of the object in the 300 dimensional space |
classification > basedOn | string | classification | the property name where the classification was based on |
classification > classifiedFields | string | classification | the classified property |
classification > completed | timestamp | classification | the time of classification completion |
classification > id | uuid | classification | the classification id |
classification > scope | list of strings | classification | the initial fields to classify |
featureProjection > vector | list of floats | featureProjection | the 2D or 3D vector coordinates of the feature projection |
Example request
import weaviate
client = weaviate.Client("http://localhost:8080")
all_objects = client.data_object.get()
print(all_objects)
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client
.data
.getter()
.withLimit(2)
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"fmt"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
data, err := client.Data().ObjectsGetter().
WithAdditional("classification").
Do(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%v", data)
}
package technology.semi.weaviate;
import java.util.List;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.data.model.WeaviateObject;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Result<List<WeaviateObject>> result = client.data().objectsGetter()
.withAdditional("classification")
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl http://localhost:8080/v1/objects?limit=2&include=classification
Create a data object
Create a new data object. The provided meta-data and schema values are validated.
Performance
💡 This endpoint is meant for individual object creations.
If you have a whole dataset that you plan on importing with Weaviate sending multiple single requests sequentially comes at a large cost:
- 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.
- It’s much more efficient to parallelize imports. This will minimize the connection overhead and use multiple threads server-side for indexing.
- 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. - Import speeds, especially for large datasets, will drastically improve when using the batching endpoint.
- Go to the
/v1/batch
endpoint.
Method and URL
POST /v1/objects
Parameters
The body of the data object for a new object takes the following fields:
name | type | required | description |
---|---|---|---|
class | string | yes | the class name as defined in the schema |
properties | array | yes | an object with the property values of the new data object |
properties > {property_name} | dataType | yes | the property and its value according to the set dataType |
id | v4 UUID | no | the given id of the data object |
Example request
import weaviate
client = weaviate.Client("http://localhost:8080")
data_obj = {
"name": "Jodi Kantor",
"writesFor": [{
"beacon": "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
}]
}
client.data_object.create(data_obj, "Author", "36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client.data
.creator()
.withClassName('Author')
.withId("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withProperties({
"name": "Jodi Kantor",
"writesFor": [{
"beacon": "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
}]
})
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"fmt"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
dataSchema := map[string]interface{}{
"name": "Jodi Kantor",
"writesFor": map[string]string{
"beacon": "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80",
},
}
created, err := client.Data().Creator().
WithClassName("Author").
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").
WithProperties(dataSchema).
Do(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%v", created)
}
package technology.semi.weaviate;
import java.util.HashMap;
import java.util.Map;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.data.model.WeaviateObject;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Map<String, Object> dataSchema = new HashMap<>();
dataSchema.put("name", "Jodi Kantor");
dataSchema.put("writesFor", new HashMap() { {
put("beacon", "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80");
} });
Result<WeaviateObject> result = client.data().creator()
.withClassName("Author")
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withProperties(dataSchema)
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
"class": "Author",
"id": "36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
"properties": {
"name": "Jodi Kantor",
"writesFor": [{
"beacon": "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80"
}]
}
}' \
http://localhost:8080/v1/objects
Create an object with geoCoordinates
If you want to fill the value of a geoCoordinates
property, you need to specify the latitude
and longitude
as decimal degrees in floats:
import weaviate
client = weaviate.Client("http://localhost:8080")
data_obj = {
"name": "Elsevier",
"headquartersGeoLocation": {
"latitude": 52.3932696,
"longitude": 4.8374263
}
}
client.data_object.create(data_obj, "Publication", "df48b9f6-ba48-470c-bf6a-57657cb07390")
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client.data
.creator()
.withClassName('Publication')
.withId("df48b9f6-ba48-470c-bf6a-57657cb07390")
.withProperties({
"name": "Elsevier",
"headquartersGeoLocation": {
"latitude": 52.3932696,
"longitude": 4.8374263
})
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"fmt"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
dataSchema := map[string]interface{}{
"name": "Elsevier",
"headquartersGeoLocation": map[string]float32{
"latitude": 52.3932696,
"longitude": 4.8374263,
},
}
created, err := client.Data().Creator().
WithClassName("Publication").
WithID("df48b9f6-ba48-470c-bf6a-57657cb07390").
WithProperties(dataSchema).
Do(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%v", created)
}
package technology.semi.weaviate;
import java.util.HashMap;
import java.util.Map;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.data.model.WeaviateObject;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Map<String, Object> dataSchema = new HashMap<>();
dataSchema.put("name", "Elsevier");
dataSchema.put("headquartersGeoLocation", new HashMap() { {
put("latitude", 52.3932696f);
put("longitude", 4.8374263f);
} });
Result<WeaviateObject> result = client.data().creator()
.withClassName("Publication")
.withID("df48b9f6-ba48-470c-bf6a-57657cb07390")
.withProperties(dataSchema)
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
"class": "Publication",
"id": "df48b9f6-ba48-470c-bf6a-57657cb07390",
"properties": {
"name": "Elsevier",
"headquartersGeoLocation": {
"latitude": 52.3932696,
"longitude": 4.8374263
}
}
}' \
http://localhost:8080/v1/objects
Create a data object with custom vectors
When you don’t want to use a vectorizer to calculate a vector for your data object, and want to enter the vector yourself, you can this this as follows.
- First, make sure that the
"vectorizer"
is set to"none"
in the right class in the data schema ("vectorizer": "none"
). This is important so Weaviate knows not to do rely on any of it’s modules to do model inference. Note: If you are running without any modules and have therefore already configured the default vectorizer to be"none"
(DEFAULT_VECTORIZER_MODULE="none"
), you can omit this step. - Then, attach the vector in a special
"vector"
field. An example of this looks like:
import weaviate
client = weaviate.Client("http://localhost:8080")
data_obj = {
"foo": "bar"
}
client.data_object.create(
data_obj,
"YourClass",
"36ddd591-2dee-4e7e-a3cc-eb86d30a0923",
vector = [0.3, 0.2, 0.1, .... 0.9], # supported types are `list`, 'numpy.ndarray`, `torch.Tensor` and `tf.Tensor`. Make sure the length matches with your Weaviate settings.
)
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
const vector = [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9];
client.data
.creator()
.withClassName('Publication')
.withId("df48b9f6-ba48-470c-bf6a-57657cb07390")
.withProperties({
"name": "Elsevier",
"headquartersGeoLocation": {
"latitude": 52.3932696,
"longitude": 4.8374263
})
.withVector(vector)
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"fmt"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
dataSchema := map[string]interface{}{
"foo": "bar",
}
vector := []float32{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9}
created, err := client.Data().Creator().
WithClassName("YourClass").
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a0923").
WithProperties(dataSchema).
WithVector(vector).
Do(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%v", created)
}
package technology.semi.weaviate;
import java.util.HashMap;
import java.util.Map;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.data.model.WeaviateObject;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Map<String, Object> dataSchema = new HashMap<>();
dataSchema.put("name", "Jodi Kantor");
dataSchema.put("writesFor", new HashMap() { {
put("beacon", "weaviate://localhost/f81bfe5e-16ba-4615-a516-46c2ae2e5a80");
} });
Float[] vector = new Float[]{0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f};
Result<WeaviateObject> result = client.data().creator()
.withClassName("Author")
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withVector(vector)
.withProperties(dataSchema)
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
"class": "YourClass",
"vector": [0.3, 0.2, 0.1, .... 0.9],
"properties": {
"foo": "bar",
}
}' \
http://localhost:8080/v1/objects
Learn here how you can search through custom vectors.
Get a data object
Collect an individual data object.
Method and URL
GET /v1/objects/{id}
Parameters
name | location | type | description |
---|---|---|---|
{id} | URL | uuid | The uuid of the data object to retrieve. |
include | URL | string | Include additional information, such as classification info. Allowed values include: classification , vector |
Example request
See here the explanation of the response fields.
import weaviate
client = weaviate.Client("http://localhost:8080")
data_object = client.data_object.get_by_id("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
print(data_object)
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client
.data
.getterById()
.withId('36ddd591-2dee-4e7e-a3cc-eb86d30a4303')
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"fmt"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
data, err := client.Data().ObjectsGetter().
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").
Do(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%v", data)
}
package technology.semi.weaviate;
import java.util.List;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.data.model.WeaviateObject;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Result<List<WeaviateObject>> result = client.data().objectsGetter()
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl http://localhost:8080/v1/objects/36ddd591-2dee-4e7e-a3cc-eb86d30a4303
Check if a data object exists without retrieving it
This endpoint can be used 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).
Method and URL
HEAD /v1/objects/{id}
Parameters
name | location | type | description |
---|---|---|---|
{id} | URL | uuid | The uuid of the data object to retrieve. |
Example request
import weaviate
client = weaviate.Client("http://localhost:8080")
exists = client.data_object.exists("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
print(exists)
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client.data
.checker()
.withId("df48b9f6-ba48-470c-bf6a-57657cb07390")
.do()
.then((exists) => {
console.log(exists)
})
.catch(err =>
console.error(err)
);
package main
import (
"context"
"fmt"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
exists, err := client.Data().Checker().
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a0923").
Do(context.Background())
if err != nil {
panic(err)
}
fmt.Printf("%v", exists)
}
package technology.semi.weaviate;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Result<Boolean> result = client.data().checker()
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl -I http://localhost:8080/v1/objects/f3e20a86-0b44-4558-a336-bd137d866387
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.
PUT /v1/objects/{id}
PATCH /v1/objects/{id}
Parameters
name | location | type | description |
---|---|---|---|
{id} | URL | uuid | The uuid of the data object to update. |
The body of the data object for a replacing (some) properties of a object takes the following fields:
name | type | required | description |
---|---|---|---|
class | string | yes | the class name as defined in the schema |
properties | array | yes | an object with the property values of the new data object |
properties > {property_name} | dataType | yes | the property and its value according to the set dataType |
Example request
import weaviate
client = weaviate.Client("http://localhost:8080")
updated_schema = {
"name": "J. Kantor"
}
# Similar to RESTful PUT request: schema will be replaced by "updated-schema"
client.data_object.update(updated_schema, "Author", "36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
# Similar to RESTful PATCH request: "updated_schema" will be merged with the existing schema, replacing only the properties in "updated_schema"
client.data_object.merge(updated_schema, "Author", "36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
var thingClassName = 'Author';
var id = '36ddd591-2dee-4e7e-a3cc-eb86d30a4303';
client.data
.getterById()
.withId(id)
.do()
.then(res => {
// alter the schema
const schema = res.schema;
schema.name = 'J. Kantor';
return client.data
.updater()
.withId(id)
.withClassName(thingClassName)
.withProperties(schema)
.do();
})
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
dataSchema := map[string]interface{}{
"name": "J. Kantor",
}
err := client.Data().Updater().
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").
WithClassName("Author").
WithProperties(dataSchema).
Do(context.Background())
if err != nil {
panic(err)
}
}
package technology.semi.weaviate;
import java.util.HashMap;
import java.util.Map;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Map<String, Object> properties = new HashMap<>();
properties.put("name", "J. Kantor");
Result<Boolean> result = client.data().updater()
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withClassName("Author")
.withProperties(properties)
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl \
-X PATCH \
-H "Content-Type: application/json" \
-d '{
"class": "Author",
"id": "36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
"properties": {
"name": "J. Kantor"
}
}' \
http://localhost:8080/v1/objects/36ddd591-2dee-4e7e-a3cc-eb86d30a4303
If the update was successful, no content will be returned.
Delete a data object
Delete an individual data object from Weaviate.
Method and URL
DELETE /v1/objects/{id}
Parameters
name | location | type | description |
---|---|---|---|
{id} | URL | uuid | The uuid of the data object to delete. |
Example request
import weaviate
client = weaviate.Client("http://localhost:8080")
client.data_object.delete("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client.data
.deleter()
.withId('36ddd591-2dee-4e7e-a3cc-eb86d30a4303')
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
err := client.Data().Deleter().
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").
Do(context.Background())
if err != nil {
panic(err)
}
}
package technology.semi.weaviate;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Result<Boolean> result = client.data().deleter()
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl -X DELETE http://localhost:8080/v1/objects/36ddd591-2dee-4e7e-a3cc-eb86d30a4303
If the deletion was successful, no content will be returned.
Validate a data object
You can validate a data object’s schema and meta data.
Method and URL
POST /v1/objects/validate
Parameters
The body of the data object for a new data object is an object taking the following field:
name | type | required | description |
---|---|---|---|
class | string | yes | the class name as defined in the schema |
properties | array | yes | an object with the property values of the new data object |
properties > {property_name} | dataType | yes | the property and its value according to the set dataType |
id | v4 uuid | no* | The id of the data object. *An ID is required by the clients. |
Example request
import weaviate
client = weaviate.Client("http://localhost:8080")
schema = {"name": "New York Times"}
valid_thing = client.data_object.validate(schema, 'Publication', 'f81bfe5e-16ba-4615-a516-46c2ae2e5a80')
print(valid_thing)
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
var schema = {"name": "New York Times"};
client.data
.validator()
.withId("f81bfe5e-16ba-4615-a516-46c2ae2e5a80")
.withClassName("Publication")
.withProperties(schema)
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
dataSchema := map[string]interface{}{
"name": "New York Times",
}
err := client.Data().Validator().
WithID("f81bfe5e-16ba-4615-a516-46c2ae2e5a80").
WithClassName("Publication").
WithProperties(dataSchema).
Do(context.Background())
if err != nil {
panic(err)
}
}
package technology.semi.weaviate;
import java.util.HashMap;
import java.util.Map;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
Map<String, Object> dataSchema = new HashMap<>();
dataSchema.put("name", "New York Times");
Result<Boolean> result = client.data().validator()
.withID("f81bfe5e-16ba-4615-a516-46c2ae2e5a80")
.withClassName("Publication")
.withProperties(dataSchema)
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
"class": "Publication",
"id": "f81bfe5e-16ba-4615-a516-46c2ae2e5a80",
"properties": {
"name": "New York Times"
}
}' \
http://localhost:8080/v1/objects/validate
If the schema of the object is valid, this request should return True
/true
in case of the clients and nothing with a plain RESTful request.
Cross-references
Add a cross reference
Method and URL
POST /v1/objects/{id}/references/{property_name}
Parameters
name | location | type | description |
---|---|---|---|
{id} | URL | uuid | The uuid of the data object to add the reference to. |
{property_name} | URL | yes | The name of the cross-reference property |
The body of the data object for a new data object is an object taking the following field:
name | type | required | description |
---|---|---|---|
beacon | v4 UUID | yes | the beacon URL of the reference |
Example request
import weaviate
client = weaviate.Client("http://localhost:8080")
client.data_object.reference.add("36ddd591-2dee-4e7e-a3cc-eb86d30a4303",
"wroteArticles", "6bb06a43-e7f0-393e-9ecf-3c0f4e129064")
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client.data
.referenceCreator()
.withId("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withReferenceProperty('wroteArticles')
.withReference(
client.data
.referencePayloadBuilder()
.withId("6bb06a43-e7f0-393e-9ecf-3c0f4e129064")
.payload(),
)
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
reference := client.Data().ReferencePayloadBuilder().WithID("6bb06a43-e7f0-393e-9ecf-3c0f4e129064").Payload()
err := client.Data().ReferenceCreator().
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").
WithReferenceProperty("wroteArticles").
WithReference(reference).
Do(context.Background())
if err != nil {
panic(err)
}
}
package technology.semi.weaviate;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.data.model.SingleRef;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
SingleRef reference = client.data().referencePayloadBuilder().withID("6bb06a43-e7f0-393e-9ecf-3c0f4e129064").payload();
Result<Boolean> result = client.data().referenceCreator()
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withReferenceProperty("wroteArticles")
.withReference(reference)
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
$ curl \
-X POST \
-H "Content-Type: application/json" \
-d '{
"beacon": "weaviate://localhost/6bb06a43-e7f0-393e-9ecf-3c0f4e129064"
}
}' \
http://localhost:8080/v1/objects/36ddd591-2dee-4e7e-a3cc-eb86d30a4303/references/wroteArticles
If the addition was successful, no content will be returned.
Update a cross reference
A PUT
request updates all references of a property of a data object.
Method and URL
PUT /v1/objects/{id}/references/{property_name}
Parameters
name | location | type | description |
---|---|---|---|
{id} | URL | uuid | The uuid of the data object to add the reference to. |
{property_name} | URL | yes | The name of the cross-reference property |
The body of the data object for a new data object is a list of beacons:
name | type | required | description |
---|---|---|---|
beacon | v4 UUID | yes | the beacon URL of the reference |
Example request
import weaviate
client = weaviate.Client("http://localhost:8080")
client.data_object.reference.update("36ddd591-2dee-4e7e-a3cc-eb86d30a4303", "wroteArticles", ["6bb06a43-e7f0-393e-9ecf-3c0f4e129064", "b72912b9-e5d7-304e-a654-66dc63c55b32"])
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client.data
.referenceReplacer()
.withId("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withReferenceProperty('wroteArticles')
.withReferences([
client.data
.referencePayloadBuilder()
.withId("6bb06a43-e7f0-393e-9ecf-3c0f4e129064")
.payload(),
client.data
.referencePayloadBuilder()
.withId("b72912b9-e5d7-304e-a654-66dc63c55b32")
.payload(),
])
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
"github.com/semi-technologies/weaviate/entities/models"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
references := &models.MultipleRef{
client.Data().ReferencePayloadBuilder().WithID("6bb06a43-e7f0-393e-9ecf-3c0f4e129064").Payload(),
client.Data().ReferencePayloadBuilder().WithID("b72912b9-e5d7-304e-a654-66dc63c55b32").Payload(),
}
err := client.Data().ReferenceReplacer().
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").
WithReferenceProperty("wroteArticles").
WithReferences(references).
Do(context.Background())
if err != nil {
panic(err)
}
}
package technology.semi.weaviate;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.data.model.SingleRef;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
SingleRef[] references = new SingleRef[]{
client.data().referencePayloadBuilder().withID("6bb06a43-e7f0-393e-9ecf-3c0f4e129064").payload(),
client.data().referencePayloadBuilder().withID("b72912b9-e5d7-304e-a654-66dc63c55b32").payload()
};
Result<Boolean> result = client.data().referenceReplacer()
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withReferenceProperty("wroteArticles")
.withReferences(references)
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
curl \
-X PUT \
-H "Content-Type: application/json" \
-d '[{
"beacon": "weaviate://localhost/6bb06a43-e7f0-393e-9ecf-3c0f4e129064"
}, {
"beacon": "weaviate://localhost/c707d9bc-840f-3997-a09a-da6dba7d0e87"
}]
}' \
http://localhost:8080/v1/objects/36ddd591-2dee-4e7e-a3cc-eb86d30a4303/references/wroteArticles
If the addition 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 this property of a data object has.
Method and URL
DELETE /v1/objects/{id}/references/{property_name}
Parameters
name | location | type | description |
---|---|---|---|
{id} | URL | uuid | The uuid of the data object to add the reference to. |
{property_name} | URL | yes | The name of the cross-reference property |
The body of the data object for a new data object is a list of beacons:
name | type | required | description |
---|---|---|---|
beacon | v4 UUID | yes | the beacon URL of the reference |
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")
const weaviate = require("weaviate-client");
const client = weaviate.client({
scheme: 'http',
host: 'localhost:8080',
});
client.data
.referenceDeleter()
.withId("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withReferenceProperty('wroteArticles')
.withReference(
client.data
.referencePayloadBuilder()
.withId("6bb06a43-e7f0-393e-9ecf-3c0f4e129064")
.payload(),
)
.do()
.then(res => {
console.log(res)
})
.catch(err => {
console.error(err)
});
package main
import (
"context"
"github.com/semi-technologies/weaviate-go-client/v4/weaviate"
)
func main() {
cfg := weaviate.Config{
Host: "localhost:8080",
Scheme: "http",
}
client := weaviate.New(cfg)
reference := client.Data().ReferencePayloadBuilder().WithID("6bb06a43-e7f0-393e-9ecf-3c0f4e129064").Payload()
err := client.Data().ReferenceDeleter().
WithID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303").
WithReferenceProperty("wroteArticles").
WithReference(reference).
Do(context.Background())
if err != nil {
panic(err)
}
}
package technology.semi.weaviate;
import technology.semi.weaviate.client.Config;
import technology.semi.weaviate.client.WeaviateClient;
import technology.semi.weaviate.client.base.Result;
import technology.semi.weaviate.client.v1.data.model.SingleRef;
public class App {
public static void main(String[] args) {
Config config = new Config("http", "localhost:8080");
WeaviateClient client = new WeaviateClient(config);
SingleRef reference = client.data().referencePayloadBuilder().withID("6bb06a43-e7f0-393e-9ecf-3c0f4e129064").payload();
Result<Boolean> result = client.data().referenceDeleter()
.withID("36ddd591-2dee-4e7e-a3cc-eb86d30a4303")
.withReferenceProperty("wroteArticles")
.withReference(reference)
.run();
if (result.hasErrors()) {
System.out.println(result.getError());
return;
}
System.out.println(result.getResult());
}
}
curl \
-X DELETE \
-H "Content-Type: application/json" \
-d '{
"beacon": "weaviate://localhost/6bb06a43-e7f0-393e-9ecf-3c0f4e129064"
}
}' \
http://localhost:8080/v1/objects/36ddd591-2dee-4e7e-a3cc-eb86d30a4303/references/wroteArticles
If the addition was successful, no content will be returned.