Skip to main content

REST - /v1/schema

LICENSEย Weaviate on Stackoverflow badgeย Weaviate issues on GitHub badgeย Weaviate version badgeย Weaviate total Docker pulls badgeย Go Report Card

note

From v1.5.0 onwards, creating a schema is optional. Learn more about Auto Schema.

Get the schemaโ€‹

Dumps the current Weaviate schema. The result contains an array of objects.

Method and URLโ€‹

GET /v1/schema

Example requestโ€‹

import weaviate

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

schema = client.schema.get()
print(schema)

Example responseโ€‹

{
"classes": [
{
"class": "Category",
"description": "Category an article is a type off",
"moduleConfig": {
"text2vec-contextionary": {
"vectorizeClassName": false
}
},
"properties": [
{
"dataType": [
"text"
],
"description": "category name",
"indexFilterable": true,
"indexSearchable": true,
"moduleConfig": {
"text2vec-contextionary": {
"vectorizePropertyName": false
}
},
"name": "name"
}
],
"vectorIndexType": "hnsw",
"vectorizer": "none"
},
{
"class": "Publication",
"description": "A publication with an online source",
"moduleConfig": {
"text2vec-contextionary": {
"vectorizeClassName": false
}
},
"properties": [
{
"dataType": [
"text"
],
"description": "Name of the publication",
"name": "name"
},
{
"dataType": [
"geoCoordinates"
],
"description": "Geo location of the HQ",
"name": "headquartersGeoLocation"
},
{
"dataType": [
"Article"
],
"description": "The articles this publication has",
"name": "hasArticles"
},
{
"dataType": [
"Article"
],
"description": "Articles this author wrote",
"name": "wroteArticles"
}
],
"vectorIndexType": "hnsw",
"vectorizer": "none"
},
{
"class": "Author",
"description": "Normalised types",
"moduleConfig": {
"text2vec-contextionary": {
"vectorizeClassName": true
}
},
"properties": [
{
"dataType": [
"text"
],
"description": "Name of the author",
"name": "name"
},
{
"dataType": [
"Publication"
],
"description": "The publication this author writes for",
"name": "writesFor"
}
],
"vectorIndexType": "hnsw",
"vectorizer": "none"
},
{
"class": "Article",
"description": "Normalised types",
"moduleConfig": {
"text2vec-contextionary": {
"vectorizeClassName": false
}
},
"properties": [
{
"dataType": [
"text"
],
"description": "title of the article",
"indexFilterable": true,
"indexSearchable": true,
"moduleConfig": {
"text2vec-contextionary": {
"vectorizePropertyName": false
}
},
"name": "title"
},
{
"dataType": [
"text"
],
"description": "url of the article",
"indexFilterable": true,
"indexSearchable": false,
"moduleConfig": {
"text2vec-contextionary": {
"vectorizePropertyName": false
}
},
"name": "url"
},
{
"dataType": [
"text"
],
"description": "summary of the article",
"indexFilterable": true,
"indexSearchable": true,
"moduleConfig": {
"text2vec-contextionary": {
"vectorizePropertyName": false
}
},
"name": "summary"
},
{
"dataType": [
"date"
],
"description": "date of publication of the article",
"name": "publicationDate"
},
{
"dataType": [
"int"
],
"description": "Words in this article",
"name": "wordCount"
},
{
"dataType": [
"Author",
"Publication"
],
"description": "authors this article has",
"name": "hasAuthors"
},
{
"dataType": [
"Publication"
],
"description": "publication this article is in",
"name": "inPublication"
},
{
"dataType": [
"Category"
],
"description": "category this article is of",
"name": "ofCategory"
},
{
"dataType": [
"boolean"
],
"description": "whether the article is currently accessible through the url",
"name": "isAccessible"
}
],
"vectorIndexType": "hnsw",
"vectorizer": "none"
}
]
}

Create a classโ€‹

Create a new data object class in the schema.

note

From v1.5.0 onwards, creating a schema is optional. Learn more about Auto Schema.

Method and URLโ€‹

POST /v1/schema

Parametersโ€‹

Learn more about the schema configuration here.

NameLocationTypeDescription
classbodystringThe name of the class. Multiple words should be concatenated in CamelCase, e.g. ArticleAuthor.
descriptionbodystringDescription of the class.
vectorIndexTypebodystringDefaults to hnsw. Can be omitted in schema definition since this is the only available type for now.
vectorIndexConfigbodyobjectVector index type specific settings.
vectorizerbodystringVectorizer to use for data objects added to this class. Default can be set via Weaviate environment variables.
moduleConfig > text2vec-contextionary > vectorizeClassNamebodyobjectInclude the class name in vector calculation (default true). Learn more about semantic indexing in Weaviate.
propertiesbodyarrayAn array of property objects.
properties > dataTypebodyarraySee the available data types.
properties > descriptionbodystringDescription of the property.
properties > moduleConfig > text2vec-contextionary > skipbodybooleanIf true, the whole property will NOT be included in vectorization. Default is false, meaning that the object will be NOT be skipped.
properties > moduleConfig > text2vec-contextionary > vectorizePropertyNamebodybooleanWhether the name of the property is used in the calculation for the vector position of data objects. Default is true. Learn more about semantic indexing in Weaviate.
properties > namebodystringThe name of the property. Multiple words should be concatenated in camelCase, e.g. nameOfAuthor.
properties > indexFilterable (available from v1.19)bodybooleanShould the data stored in this property be indexed with the filterable, Roaring Bitmap index? Read more about indexing in Weaviate.
properties > indexSearchable (available from v1.19)bodybooleanShould the data stored in this property be indexed to allow BM25/hybrid-search index? Read more on how to configure indexing in Weaviate.
properties > indexInverted (deprecated)bodybooleanShould the data stored in this property be indexed? Learn more about indexing in Weaviate.
properties > tokenizationbodystringOnly for string/text props. Introduced in v1.12.0. Control how a field is tokenized in the inverted index. Defaults to "word", can be set to "field". Learn more about property tokenization.
invertedIndexConfig > stopwordsbodyobjectConfigure which words should be treated as stopwords and therefore be ignored on querying (stopwords are still indexed).
Since v1.18, stopwords can be configured at runtime.
See more details here.
invertedIndexConfig > indexTimestampsbodybooleanMaintain an inverted index for each object by its internal timestamps, currently including creationTimeUnix and lastUpdateTimeUnix.
See more details here.
replicationConfig > factorbodyintThe replication factor, aka the number of copies in a replicated Weaviate setup.

Example request for creating a classโ€‹

import weaviate

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

class_obj = {
"class": "Article",
"description": "A written text, for example a news article or blog post",
"properties": [
{
"dataType": ["text"],
"description": "Title of the article",
"name": "title",
},
{
"dataType": ["text"],
"description": "The content of the article",
"name": "content"
}
]
}

client.schema.create_class(class_obj)

Or with all the possible parameters:

import weaviate

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

class_obj = {
"class": "Article",
"description": "A written text, for example a news article or blog post",
"vectorIndexType": "hnsw",
"vectorIndexConfig": {
"distance": "cosine",
"efConstruction": 128,
"maxConnections": 64
},
"vectorizer": "text2vec-contextionary",
"moduleConfig": {
"text2vec-contextionary": {
"vectorizeClassName": True
}
},
"properties": [
{
"dataType": [
"text"
],
"description": "Title of the article",
"name": "title",
"indexInverted": True,
"moduleConfig": {
"text2vec-contextionary": {
"skip": False,
"vectorizePropertyName": False
}
}
},
{
"dataType": [
"text"
],
"description": "The content of the article",
"name": "content",
"indexInverted": True,
"moduleConfig": {
"text2vec-contextionary": {
"skip": False,
"vectorizePropertyName": False
}
}
}
],
"shardingConfig": {
"virtualPerPhysical": 128,
"desiredCount": 1,
"desiredVirtualCount": 128,
"key": "_id",
"strategy": "hash",
"function": "murmur3"
},
"invertedIndexConfig": {
"stopwords": {
"preset": "en",
"additions": ["star", "nebula"],
"removals": ["a", "the"]
},
"indexTimestamps": True
},
"replicationConfig": {
"factor": 3
}
}

client.schema.create_class(class_obj)

Get a single class from the schemaโ€‹

Retrieves the configuration of a single class in the schema.

Method and URLโ€‹

GET /v1/schema/{ClassName}

Example requestโ€‹

import weaviate

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

schema = client.schema.get("Article")
print(schema)

Delete a classโ€‹

Remove a class (and all data in the instances) from the schema.

Method and URLโ€‹

DELETE v1/schema/{class_name}

URL parametersโ€‹

NameLocationTypeDescription
{class_name}pathstringThe name of the class

Example request for deleting a classโ€‹

import weaviate

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

client.schema.delete_class("Article") # deletes the class "Article" along with all data points of class "Article"
# OR
client.schema.delete_all() # deletes all classes along with the whole data

Update a classโ€‹

Update settings of an existing schema class.

Use this endpoint to alter an existing class in the schema. Note that not all settings are mutable. If an error about immutable fields is returned and you still need to update this particular setting, you will have to delete the class (and the underlying data) and recreate. This endpoint cannot be used to modify properties. Instead, use POST /v1/schema/{ClassName}/properties. A typical use case for this endpoint is to update configuration, such as the vectorIndexConfig. Note that even in mutable sections, such as vectorIndexConfig, some fields may be immutable.

You should attach a body to this PUT request with the entire new configuration of the class.

Method and URLโ€‹

PUT v1/schema/{class_name}

Parametersโ€‹

The URL must contain the following parameter:

NameLocationTypeDescription
{class_name}pathstringThe name of the class

Parameters in the PUT body:

NameLocationTypeDescription
classbodystringThe name of the class. Multiple words should be concatenated in CamelCase, e.g. ArticleAuthor.
descriptionbodystringDescription of the class.
vectorIndexTypebodystringDefaults to hnsw. Can be omitted in schema definition since this is the only available type for now.
vectorIndexConfigbodyobjectVector index type specific settings.
vectorizerbodystringVectorizer to use for data objects added to this class. Default can be set via Weaviate environment variables.
moduleConfig > text2vec-contextionary > vectorizeClassNamebodyobjectInclude the class name in vector calculation (default true). Learn more about how to configure indexing in Weaviate.
propertiesbodyarrayAn array of property objects.
properties > dataTypebodyarraySee the available data types
properties > descriptionbodystringDescription of the property.
properties > moduleConfig > text2vec-contextionary > skipbodybooleanIf true, the whole property will NOT be included in vectorization. Default is false, meaning that the object will be NOT be skipped.
properties > moduleConfig > text2vec-contextionary > vectorizePropertyNamebodybooleanWhether the name of the property is used in the calculation for the vector position of data objects. Default is true. Learn more about how to configure indexing in Weaviate.
properties > namebodystringThe name of the property. Multiple words should be concatenated in camelCase, e.g. nameOfAuthor.
properties > indexFilterable (available from v1.19)bodybooleanShould the data stored in this property be indexed with the filterable, Roaring Bitmap index? Read more about indexing in Weaviate.
properties > indexSearchable (available from v1.19)bodybooleanShould the data stored in this property be indexed to allow BM25/hybrid-search index? Read more about indexing in Weaviate.
properties > indexInverted (deprecated)bodybooleanShould the data stored in this property be indexed? Learn more about indexing in Weaviate.
properties > tokenizationbodystringOnly for string/text props. Introduced in v1.12.0. Control how a field is tokenized in the inverted index. Defaults to "word". If string is used, can be set to "field". Learn more about property tokenization.
invertedIndexConfig > stopwordsbodyobjectConfigure which words should be treated as stopwords and therefore be ignored when querying (stopwords are still indexed).
Sincev1.18, stopwords can be configured at runtime.
See more details here.
invertedIndexConfig > indexTimestampsbodybooleanMaintain an inverted index for each object by its internal timestamps, currently including creationTimeUnix and lastUpdateTimeUnix See more details here.

Example request for updating a classโ€‹

import weaviate

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

class_obj = {
"class": "Article",
"description": "A written text, for example a news article or blog post",
"properties": [
{
"dataType": [
"string"
],
"description": "Title of the article",
"name": "title",
},
{
"dataType": [
"text"
],
"description": "The content of the article",
"name": "content"
}
]
}

client.schema.update_config("Article", class_obj)

Add a propertyโ€‹

Method and URLโ€‹

POST v1/schema/{class_name}/properties

Parametersโ€‹

NameLocationTypeDescription
dataTypebodyarrayAn available data type.
descriptionbodystringDescription of the property.
moduleConfig > text2vec-contextionary > skipbodybooleanIf true, the whole property will NOT be included in vectorization. Default is false, meaning that the object will be NOT be skipped.
moduleConfig > text2vec-contextionary > vectorizePropertyNamebodybooleanWhether the name of the property is used in the calculation for the vector position of data objects. Default is true. Learn more about how to configure indexing in Weaviate.
namebodystringThe name of the property. Multiple words should be concatenated in camelCase like nameOfAuthor.
indexFilterable (available from v1.19)bodybooleanShould the data stored in this property be indexed with the filterable, Roaring Bitmap index? Read more about indexing in Weaviate.
indexSearchable (available from v1.19)bodybooleanShould the data stored in this property be indexed to allow BM25/hybrid-search index? Read more about indexing in Weaviate.
indexInverted (deprecated)bodybooleanShould the data stored in this property be indexed? Learn more about indexing in Weaviate.

Example request for adding a propertyโ€‹

import weaviate

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

add_prop = {
"dataType": [
"boolean"
],
"name": "onHomepage"
}

client.schema.property.create("Article", add_prop)

Inspect the shards of a classโ€‹

As described in Architecture > Storage, creation of a class leads to creating an index which manages all the disk storage and vector indexing. An index itself can be comprised of multiple shards. If a class index is used on multiple nodes of a multi-node Weaviate cluster there must be at least one shard per node.

You can view a list of all shards for a particular class:

Method and URLโ€‹

note

This API was added in v1.12.0.

GET v1/schema/{class_name}/shards

Parametersโ€‹

NameLocationTypeDescription
{class_name}URL pathstringThe name of the class

Example request viewing shards of a classโ€‹

import weaviate

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

client.schema.get_class_shards("Article")

Update shard statusโ€‹

A shard may have been marked as read-only, for example because the disk was full. You can manually set a shard to READY again using the following API. There is also a convenience function in each client to set the status of all shards of a class.

Method and URLโ€‹

note

This API was added in v1.12.0

PUT v1/schema/{class_name}/shards/{shard_name}

Parametersโ€‹

NameLocationTypeDescription
{class_name}URL pathstringThe name of the class.
{shard_name}URL pathstringThe name/id of the shard.
statusbodystringThe status to update the shard to. One of READONLY, READY.

Example requests to update the status of a shardโ€‹

import weaviate

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

# Update a shard
client.schema.update_class_shard(
class_name="Article",
status="READONLY",
shard_name="shard-1234",
)

# Convenience method to update all shards in a class
client.schema.update_class_shard(
class_name="Article",
status="READONLY",
)

More Resourcesโ€‹

If you can't find the answer to your question here, please look at the:

  1. Frequently Asked Questions. Or,
  2. Knowledge base of old issues. Or,
  3. For questions: Stackoverflow. Or,
  4. For more involved discussion: Weaviate Community Forum. Or,
  5. We also have a Slack channel.