Skip to main content

GraphQL - Get{}

LICENSEΒ Weaviate on Stackoverflow badgeΒ Weaviate issues on Github badgeΒ Weaviate version badgeΒ Weaviate total Docker pulls badgeΒ Go Report Card

Get{} syntax and query structure​

A Get{} function is always based on the schema. For example, if you've created a schema with a class Articles which has the properties title, url and wordCount, you can query it as follows:

{
Get {
Article {
title
url
wordCount
}
}
}

🟒 Try out this GraphQL example in the Weaviate Console.

The above query will result in something like the following:

{
"data": {
"Get": {
"Article": [{
"title": "β€œJoker” Is a Viewing Experience of Rare, Numbing Emptiness",
"url": "https://www.newyorker.com/culture/the-front-row/joker-is-a-viewing-experience-of-rare-numbing-emptiness",
"wordCount": 1794
}]
}
}
}

Query beacon references​

If you've set a beacon reference in the schema, you can query it as follows:

{
Get {
Article {
title
url
wordCount
inPublication { # the reference
... on Publication { # you always set the destination class
name # the property related to target class
}
}
}
}
}

🟒 Try out this GraphQL example in the Weaviate Console.

The above query will result in something like the following:

{
"data": {
"Get": {
"Article": [{
"title": "β€œJoker” Is a Viewing Experience of Rare, Numbing Emptiness",
"url": "https://www.newyorker.com/culture/the-front-row/joker-is-a-viewing-experience-of-rare-numbing-emptiness",
"wordCount": 1794,
"inPublication": [
{
"name": "New Yorker"
}
]
}]
}
}
}

Additional properties​

For every Get{} request you can get additional information about the returned data object(s) by using additional properties. You can recognize these properties because they are in the object _additional{}. Additional properties can help you interpret query results and can for example be used for projection and visualization of the retrieved data. An overview of all additional properties and how to use them is documented here.

Vector Search Operators​

To combine Get { } with a vector search argument, here is an overview of the supported arguments and links to their detailed documentation:

ArgumentDescriptionRequired Modules (at least one of)Learn More
nearObjectFind the nearest neighbors of an object referenced by its idnone - works out of the boxLearn more
nearVectorFind the nearest neighbors to any vectornone - works out of the boxLearn more
nearTextVectorize a text query and perform a vector search based on ittext2vec-transformers, text2vec-contextionary, text2vec-openai, multi2vec-clip, text2vec-huggingface, text2vec-cohereTransformers, Contextionary, OpenAI, CLIP, Huggingface, Cohere
nearImageVectorize an image and perform a vector search based on itmulti2vec-clip, img2vec-neuralCLIP, Img2Vec
hybridCombine dense and sparse vectors to deliver best of both search methodsnone - works out of the boxLearn more
bm25Keyword search with BM25F rankingnone - works out of the boxLearn more

Filters​

Get{} functions can be extended with search filters (both semantic filters as traditional filters). Because the filters work on multiple core functions (like Aggregate{}) there is a specific documentation page dedicated to filters.

Sorting​

Note: Support for sorting was added in v1.13.0.

You can sort results by any primitive property, typically a text, string, number, or int property. When a query has a natural order (e.g. because of a near<Media> vector search), adding a sort operator will override the order.

See filters – sorting for more information.

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 issues: Github. Or,
  5. Ask your question in the Slack channel: Slack.