Table of documentation contents

Get Guide

The Get{} function is Weaviate’s bread and butter. The most direct way to access data.

Index

Basics

  • Weaviate’s query language is GraphQL.
  • You can query a Weaviate after you’ve created a schema and populated it with data.
  • You can easily query a Weaviate by using the GraphQL interface inside a Weaviate Playground.
  • Some functions have (semantic) filters available.

Introduction

The Get{} function is the most straight-ahead function Weaviate has. It is the most direct wat to collect data from a weaviate. Especially when you combine them with filters, you can easily browse your Weaviate.

Define a query

You can query Weaviate for semantic kinds based on standard GraphQL queries. The examples below only contain the GraphQL query. You can POST a GraphQL query to Weaviate as follows:

$ curl http://localhost/v1/graphql -X POST -H 'Content-type: application/json' -d '{GraphQL query}'

A GraphQL JSON object is defined as:

{
    "query": "{ # GRAPHQL QUERY }"
}

Get{} Function

Get{} query structure and syntax

The Get{} function is always defined based on the following principle:

{
  Get {
    <SematicKind> {
      <Class> {
        <property>
        <PropertyWithReference>
          ... on <ClassOfBeacon> {
            <property>
          }
      }
    }
  }
}

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 name and publicationDate, you can query it as follows:

{
  Get {
    Things {
      Article {
        title
        url
        wordCount
      }
    }
  }
}

🟢 Click here to try out this graphql example in the Weaviate Playground.

The above query will result in something like the following:

{
  "data": {
    "Get": {
      "Things": {
        "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
        }]
      }
    }
  }
}

Work with graph beacons

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

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

🟢 Click here to try out this graphql example in the Weaviate Playground.

Note that if you’ve set the cardinality to many, you might have multiple data types. For example:

{
  Get {
    Things {
      Article {
        title
        url
        wordCount
        HasAuthors {
          ... on Author {
            name
          }
          ... on Publication {
            name
          }
        }
      }
    }
  }
}

🟢 Click here to try out this graphql example in the Weaviate Playground.

More Resources

If you can’t find the answer to your question here, please use the:

  1. Knowledge base of old issues. Or,
  2. For questions: Stackoverflow. Or,
  3. For issues: Github.
  4. For Frequently Asked Questions.
Tags
  • Query
  • GraphQL