Course contentsShow
← AI Engineering
Lesson 309 of 1,8868. Vector Databases - ToolsFree lesson

Weaviate: GraphQL Queries and Filters

Querying Weaviate using GraphQL, combining vector search with property filters, and exploring result objects.

Weaviate: GraphQL Queries and Filters

You'll learn how to query Weaviate using GraphQL to combine vector similarity search with precise property filters.

Why GraphQL for Vector Search?

Weaviate uses GraphQL as its query language, which lets you express complex queries in a structured, readable way. Think of it like ordering at a restaurant where you can specify exactly what you want (the dish), how you want it prepared (filters), and how much you want (limit) — all in one clear request.

Core Query Structure

Weaviate's GraphQL queries have three main components:

  1. Get queries — Retrieve objects from a collection (called a "class" in Weaviate)
  2. Vector search with nearVector or nearText — Find semantically similar items
  3. Property filters with where — Add traditional conditions (like price < 100 or category = "electronics")

Combining Vector and Metadata Filtering

The real power emerges when you combine these. You might search for "comfortable running shoes" (semantic query) but only want results where price < 80 and inStock = true (metadata filters). Weaviate evaluates both constraints efficiently, giving you relevant results that meet your criteria.

The result objects include not just the matched data, but also metadata like similarity scores (certainty or distance) and the actual vector if needed.

Result Exploration

GraphQL lets you specify exactly which fields to return — no over-fetching or under-fetching. You can retrieve the object's properties, its vector, or even references to related objects in your schema.

Key Takeaway: Weaviate's GraphQL interface lets you blend semantic vector search with traditional property filters in a single, declarative query — giving you both similarity and precision simultaneously.