---
title: "Quickstart: Locally hosted with Docker"
description: "Weaviate is an open-source vector database built to power AI applications. This quickstart guide will show you how to:"
url: https://docs.weaviate.io/weaviate/quickstart/local
---

# Quickstart: Locally hosted with Docker

Weaviate is an open-source vector database built to power AI applications. This quickstart guide will show you how to:

1. **Set up a collection** - Create a collection and import data into it.
2. **Search** - Perform a similarity (vector) search on your data.
3. **RAG** - Perform Retrieval Augmented Generation (RAG) with a generative model.

If you encounter any issues along the way or have additional questions, use the Ask AI feature.

## Prerequisites

Before we get started, install [Docker](https://docs.docker.com/get-started/get-docker/) on your machine. We will be running Weaviate and Ollama language models locally. We recommend that you use a modern computer with at least 8GB of RAM, preferably 16GB or more.

> [!NOTE]
>
> **Telemetry**
>
> To help us improve Weaviate and understand community usage trends, Weaviate collects telemetry data by default. To learn more or opt-out, click [here](https://docs.weaviate.io/deploy/configuration/telemetry).

---

## Start Weaviate and Ollama with Docker Compose

Save the following code to a file named `docker-compose.yml` in your project directory.

```yaml
services:
  weaviate:
    command:
    - --host
    - 0.0.0.0
    - --port
    - '8080'
    - --scheme
    - http
    image: cr.weaviate.io/semitechnologies/weaviate:1.40.4
    ports:
    - 8080:8080
    - 50051:50051
    volumes:
    - weaviate_data:/var/lib/weaviate
    restart: on-failure:0
    environment:
      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: 'true'
      PERSISTENCE_DATA_PATH: '/var/lib/weaviate'
      ENABLE_MODULES: 'text2vec-ollama,generative-ollama'
      CLUSTER_HOSTNAME: 'node1'
    depends_on:
      - ollama

  ollama:
    image: ollama/ollama:0.12.9
    ports:
      - "11434:11434"
    volumes:
      - ollama_data:/root/.ollama

volumes:
  weaviate_data:
  ollama_data:
```

Run the following command to start a Weaviate instance and the Ollama server inside Docker containers:

```bash
docker compose up -d
```

Once the Ollama service starts, you can pull the required embedding model ([`nomic-embed-text`](https://ollama.com/library/nomic-embed-text)) and generative model ([`llama3.2`](https://ollama.com/library/llama3.2)) in the `ollama` container:

```bash
docker compose exec ollama ollama pull nomic-embed-text
docker compose exec ollama ollama pull llama3.2
```

---

## Install a client library

Follow the instructions below to install one of the official client libraries, available in [Python](https://docs.weaviate.io/weaviate/client-libraries/python), [JavaScript/TypeScript](https://docs.weaviate.io/weaviate/client-libraries/typescript), [Go](https://docs.weaviate.io/weaviate/client-libraries/go), and [Java](https://docs.weaviate.io/weaviate/client-libraries/java).

**Python**

```bash
pip install -U "weaviate-client[agents]"
```

**JavaScript/TypeScript**

```bash
npm install @weaviate/node @weaviate/agents
```

**Go (v5)**

```bash
go get github.com/weaviate/weaviate-go-client/v5
```

**Go (v6)**

```bash
go get github.com/weaviate/weaviate-go-client/v6
```

**Java**

```xml
<dependency>
  <groupId>io.weaviate</groupId>
  <artifactId>client6</artifactId>
  <version>6.3.1</version> <!-- Check latest version: https://github.com/weaviate/java-client  -->
</dependency>
```

**C#**

```xml
<PackageReference Include="Weaviate.Client" Version="1.0.0" />
```

**Verify your setup**

Before you create anything, you can also check that the client can reach your cluster:

**Python**

quickstart\_check\_readiness.py

```py
import weaviate

client = weaviate.connect_to_local()

print(client.is_ready())  # Should print: `True`

client.close()  # Free up resources
```

**JavaScript/TypeScript**

quickstart\_check\_readiness.ts

```ts
import weaviate, { WeaviateClient } from '@weaviate/node';

const client: WeaviateClient = await weaviate.connectToLocal();

var clientReadiness = await client.isReady();

console.log(clientReadiness); // Should return `true`

client.close(); // Close the client connection
```

**Go (v5)**

quickstart/1\_check\_readiness/main.go

```go
package main

import (
    "context"
    "fmt"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
)

func main() {
    cfg := weaviate.Config{
        Host:   "localhost:8080",
        Scheme: "http",
    }

    client, err := weaviate.NewClient(cfg)
    if err != nil {
        fmt.Println(err)
    }

    // Check the connection
    ready, err := client.Misc().ReadyChecker().Do(context.Background())
    if err != nil {
        panic(err)
    }
    fmt.Printf("%v", ready)
}
```

**Java**

```java
WeaviateClient client = WeaviateClient.connectToLocal();
System.out.println(client.isReady()); // Should print: `True`

client.close(); // Free up resources
```

**C#**

```csharp
using var client = await Connect.Local();

// GetMeta returns server info. A successful call indicates readiness.
var meta = await client.GetMeta();
Console.WriteLine(meta);

// The 'using' statement handles freeing up resources automatically.
```

**Curl**

```bash
curl -w "\nResponse code: %{http_code}\n" \
  http://localhost:8080/v1/.well-known/ready

# You should see "Response code: 200" if the instance is ready
```

Run `docker compose ps` to confirm both containers are up. Some common first errors include:

| What you see | What it means |
| - | - |
| `Unfortunately, the gRPC health check against Weaviate could not be completed.` | The client reached REST on `8080` but not gRPC on `50051`. Check that the compose file publishes `50051:50051` and that nothing else holds the port. |
| `unauthorized: invalid api key` (HTTP 401) | The instance expects a key. The compose file above enables anonymous access, so connect without credentials, or pass the key you configured. |
| `no vectorizer found for class "Movie"` | You ran a `nearText` query against a collection that has no vectorizer. Create the collection with a vectorizer, or query with `nearVector` and supply the vector yourself. |
| A connection error naming the Ollama endpoint | Weaviate could not reach Ollama. Inside Compose the endpoint is the service name, `http://ollama:11434`, not `localhost`. Confirm you pulled the models with `docker compose exec ollama ollama pull ...`. |
| `Con004: The connection to Weaviate was not closed properly.` | The script finished without closing the client. Call `client.close()`, or use a context manager. |

---

## Step 1: Create a collection & import data

There are two paths you can choose from when importing data:

[Vectorize objects during import\
(recommended)](https://docs.weaviate.io/weaviate/quickstart/local?import=vectorization#create-a-collection): Import objects and vectorize them with the Ollama embedding model.

[Import vectors](https://docs.weaviate.io/weaviate/quickstart/local?import=custom-embeddings#create-a-collection): Import pre-computed vector embeddings along with your data.



#### Vectorize objects during import

The following example creates a collection called `Movie` with the [Ollama](https://docs.weaviate.io/weaviate/model-providers/ollama/embeddings) embedding model provider (`text2vec-ollama`) for vectorizing data during import and for querying. You are also free to use any other available [embedding model provider](https://docs.weaviate.io/weaviate/model-providers).

**Python**

```py
import weaviate
from weaviate.classes.config import Configure

# Step 1.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:
    # Step 1.2: Create a collection
    movies = client.collections.create(
        name="Movie",
        vector_config=Configure.Vectors.text2vec_ollama(  # Configure the Ollama embedding integration
            api_endpoint="http://ollama:11434",  # If using Docker you might need: http://host.docker.internal:11434
            model="nomic-embed-text",  # The model to use
        ),
    )

    # Step 1.3: Import three objects
    data_objects = [
        {"title": "The Matrix", "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.", "genre": "Science Fiction"},
        {"title": "Spirited Away", "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.", "genre": "Animation"},
        {"title": "The Lord of the Rings: The Fellowship of the Ring", "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.", "genre": "Fantasy"},
    ]

    movies = client.collections.use("Movie")
    movies.data.ingest(data_objects)

    print(f"Imported & vectorized {len(movies)} objects into the Movie collection")
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, vectors } from '@weaviate/node';

// Step 1.1: Connect to your local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal();

// Step 1.2: Create a collection
const movies = await client.collections.create({
  name: 'Movie',
  vectorizers: vectors.text2VecOllama({  // Configure the Ollama embedding integration
    apiEndpoint: 'http://ollama:11434',  // If using Docker you might need: http://host.docker.internal:11434
    model: 'nomic-embed-text',           // The model to use
  }),
});

// Step 1.3: Import three objects
const dataObjects = [
  { title: 'The Matrix', description: 'A computer hacker learns about the true nature of reality and his role in the war against its controllers.', genre: 'Science Fiction' },
  { title: 'Spirited Away', description: 'A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.', genre: 'Animation' },
  { title: 'The Lord of the Rings: The Fellowship of the Ring', description: 'A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.', genre: 'Fantasy' },
];

const movieCollection = client.collections.get('Movie');
await movieCollection.data.ingest(
  dataObjects.map((properties) => ({ properties }))
);

console.log(`Imported & vectorized ${dataObjects.length} objects into the Movie collection`);

await client.close(); // Free up resources
```

**Go (v5)**

The collection also contains a configuration for the generative (RAG) integration:

- Ollama [generative AI integrations](https://docs.weaviate.io/weaviate/model-providers/ollama/generative) for retrieval augmented generation (RAG).

```go
import (
    "context"
    "fmt"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate/entities/models"
)

func main() {
    // Step 1.1: Connect to your local Weaviate instance
    cfg := weaviate.Config{
        Host:   "localhost:8080",
        Scheme: "http",
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 1.2: Create a collection
    classObj := &models.Class{
        Class:      "Movie",
        Vectorizer: "text2vec-ollama",
        ModuleConfig: map[string]interface{}{
            "text2vec-ollama": map[string]interface{}{ // Configure the Ollama embedding integration
                "apiEndpoint": "http://ollama:11434", // If using Docker you might need: http://host.docker.internal:11434
                "model":       "nomic-embed-text",    // The model to use
            },
            "generative-ollama": map[string]interface{}{ // Configure the Ollama generative integration
                "apiEndpoint": "http://ollama:11434", // If using Docker you might need: http://host.docker.internal:11434
                "model":       "llama3.2",            // The model to use
            },
        },
    }

    err = client.Schema().ClassCreator().WithClass(classObj).Do(context.Background())
    if err != nil {
        panic(err)
    }

    // Step 1.3: Import three objects
    dataObjects := []map[string]interface{}{
        {
            "title":       "The Matrix",
            "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
            "genre":       "Science Fiction",
        },
        {
            "title":       "Spirited Away",
            "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
            "genre":       "Animation",
        },
        {
            "title":       "The Lord of the Rings: The Fellowship of the Ring",
            "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
            "genre":       "Fantasy",
        },
    }

    // Insert objects
    objects := make([]*models.Object, len(dataObjects))
    for i, obj := range dataObjects {
        objects[i] = &models.Object{
            Class:      "Movie",
            Properties: obj,
        }
    }

    _, err = client.Batch().ObjectsBatcher().WithObjects(objects...).Do(context.Background())
    if err != nil {
        panic(err)
    }

    fmt.Printf("Imported & vectorized %d objects into the Movie collection\n", len(dataObjects))
```

**Go (v6)**

> [!NOTE]
>
> **Go client `v6`**
>
> This tab uses the [`v6` Go client](https://docs.weaviate.io/weaviate/client-libraries/go). It vectorizes data with the [Ollama embedding integration](https://docs.weaviate.io/weaviate/model-providers/ollama/embeddings) (the `text2vec-ollama` module), like the other tabs. Collection-level generative (RAG) configuration is not yet available in the client, so it is omitted here (see Step 3).

```go
package main

import (
  "context"
  "fmt"

  weaviate "github.com/weaviate/weaviate-go-client/v6"
  "github.com/weaviate/weaviate-go-client/v6/collections"
  "github.com/weaviate/weaviate-go-client/v6/data"
)

// The client has no typed Ollama vectorizer yet, so this small custom module
// type names text2vec-ollama. Its JSON-tagged fields are the module settings.
type text2vecOllama struct {
  APIEndpoint string `json:"apiEndpoint,omitempty"`
  Model       string `json:"model,omitempty"`
}

func (text2vecOllama) Name() string { return "text2vec-ollama" }

func main() {
  ctx := context.Background()

  // Step 1.1: Connect to your local Weaviate instance.
  client, err := weaviate.NewLocal(ctx)
  if err != nil {
    // handle error
    panic(err)
  }
  defer client.Close()

  // Step 1.2: Create a collection vectorized by the Ollama embedding integration.
  if _, err := client.Collections.Create(ctx, collections.Collection{
    Name: "Movie",
    Properties: []collections.Property{
      {Name: "title", DataType: collections.DataTypeText},
      {Name: "description", DataType: collections.DataTypeText},
      {Name: "genre", DataType: collections.DataTypeText},
    },
    Vectors: map[string]collections.VectorConfig{
      "default": {Vectorizer: text2vecOllama{
        APIEndpoint: "http://ollama:11434", // If using Docker you might need: http://host.docker.internal:11434
        Model:       "nomic-embed-text",
      }},
    },
  }); err != nil {
    // handle error
    panic(err)
  }

  // Step 1.3: Import a few objects. The server vectorizes each one on import.
  if _, err := client.Collections.Use("Movie").Data.Insert(ctx,
    &data.Object{Properties: map[string]any{
      "title":       "The Matrix",
      "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
      "genre":       "Science Fiction",
    }},
    &data.Object{Properties: map[string]any{
      "title":       "Spirited Away",
      "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
      "genre":       "Animation",
    }},
    &data.Object{Properties: map[string]any{
      "title":       "The Lord of the Rings: The Fellowship of the Ring",
      "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
      "genre":       "Fantasy",
    }},
  ); err != nil {
    // handle error
    panic(err)
  }

  fmt.Println("Imported & vectorized 3 objects into the Movie collection")
}
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.Property;
import io.weaviate.client6.v1.api.collections.VectorConfig;
import io.weaviate.client6.v1.api.collections.WeaviateObject;
import io.weaviate.client6.v1.api.collections.batch.BatchContext;

import java.util.List;
import java.util.Map;

public class QuickstartLocalCreate {

  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;
    String collectionName = "Movie";

    try {
      // Step 1.1: Connect to your local Weaviate instance
      client = WeaviateClient.connectToLocal();
      // Step 1.2: Create a collection
      client.collections.create(collectionName,
          col -> col.vectorConfig(VectorConfig.text2vecOllama(v -> v
              // If using Docker you might need: http://host.docker.internal:11434
              .apiEndpoint("http://ollama:11434")
              .model("nomic-embed-text") // The model to use
          ))
              // Define properties for the collection
              .properties(Property.text("title"), Property.text("description"),
                  Property.text("genre")));

      // Step 1.3: Import three objects
      List<Map<String, Object>> dataObjects = List.of(Map.of("title",
          "The Matrix", "description",
          "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
          "genre", "Science Fiction"),
          Map.of("title", "Spirited Away", "description",
              "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
              "genre", "Animation"),
          Map.of("title", "The Lord of the Rings: The Fellowship of the Ring",
              "description",
              "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
              "genre", "Fantasy"));

      // Insert the objects using server-side batching
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use(collectionName);
      BatchContext<Map<String, Object>> batch = movies.batch.start();
      // Closing the batch sends the remaining objects and waits for the results
      try (batch) {
        for (Map<String, Object> properties : dataObjects) {
          batch.add(
              WeaviateObject.<Map<String, Object>>of(o -> o.properties(properties)));
        }
      }

      if (batch.numberOfErrors() > 0) {
        System.err
            .println("Number of failed imports: " + batch.numberOfErrors());
      } else {
        System.out.println("Imported & vectorized " + dataObjects.size()
            + " objects into the Movie collection");
      }
    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;

namespace WeaviateProject.Examples
{
    public class QuickstartLocalCreate
    {
public static async Task Run()
{
    string collectionName = "Movie";

    // Step 1.1: Connect to your local Weaviate instance
    var client = await Connect.Local();

    // Step 1.2: Create a collection
    var movies = await client.Collections.Create(
        new CollectionCreateParams
        {
            Name = collectionName,
            VectorConfig = Configure.Vector(
                "default",
                v =>
                    v.Text2VecOllama(
                        apiEndpoint: "http://ollama:11434",
                        model: "nomic-embed-text"
                    )
            ),
            // Define properties for the collection
            Properties =
            [
                Property.Text("title"),
                Property.Text("description"),
                Property.Text("genre"),
            ],
        }
    );

    // Step 1.3: Import three objects
    var dataObjects = new List<object>
    {
        new
        {
            title = "The Matrix",
            description = "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
            genre = "Science Fiction",
        },
        new
        {
            title = "Spirited Away",
            description = "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
            genre = "Animation",
        },
        new
        {
            title = "The Lord of the Rings: The Fellowship of the Ring",
            description = "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
            genre = "Fantasy",
        },
    };

    // Insert the objects using server-side batching
    var insertResponse = await movies.Batch.InsertMany(dataObjects);

    if (insertResponse.HasErrors)
    {
        Console.WriteLine($"Errors during import: {insertResponse.Errors}");
    }
    else
    {
        Console.WriteLine(
            $"Imported & vectorized {insertResponse.Count} objects into the Movie collection"
        );
    }
}
    }
}
```

#### Import vectors

The following example creates a collection called `Movie`. The data should already contain the pre-computed vector embeddings. This option is useful for when you are migrating data from a different vector database.

**Python**

```py
import weaviate
from weaviate.classes.config import Configure
from weaviate.classes.data import DataObject

# Step 1.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:

    # Step 1.2: Create a collection
    movies = client.collections.create(
        name="Movie",
        vector_config=Configure.Vectors.self_provided(),  # No automatic vectorization since we're providing vectors
    )

    # Step 1.3: Import three objects
    data_objects = [
        {"properties": {"title": "The Matrix", "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.", "genre": "Science Fiction"},
        "vector": [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]},
        {"properties": {"title": "Spirited Away", "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.", "genre": "Animation"},
        "vector": [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]},
        {"properties": {"title": "The Lord of the Rings: The Fellowship of the Ring", "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.", "genre": "Fantasy"},
        "vector": [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0]}
    ]

    # Insert the objects with vectors
    movies = client.collections.get("Movie")
    movies.data.ingest(
        DataObject(properties=obj["properties"], vector=obj["vector"])
        for obj in data_objects
    )

    print(
        f"Imported {len(data_objects)} objects with vectors into the Movie collection"
    )
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, vectors } from '@weaviate/node';

// Step 1.1: Connect to your local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal();

// Step 1.2: Create a collection
const movies = await client.collections.create({
  name: 'Movie',
  vectorizers: vectors.selfProvided(), // No automatic vectorization since we're providing vectors
});

// Step 1.3: Import three objects
const dataObjects = [
  {
    properties: { title: 'The Matrix', description: 'A computer hacker learns about the true nature of reality and his role in the war against its controllers.', genre: 'Science Fiction' },
    vectors: [0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8],
  },
  {
    properties: { title: 'Spirited Away', description: 'A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.', genre: 'Animation' },
    vectors: [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9],
  },
  {
    properties: { title: 'The Lord of the Rings: The Fellowship of the Ring', description: 'A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.', genre: 'Fantasy' },
    vectors: [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0],
  },
];

// Insert the objects with vectors
const movieCollection = client.collections.get('Movie');
await movieCollection.data.ingest(dataObjects);

console.log(`Imported ${dataObjects.length} objects with vectors into the Movie collection`);

await client.close(); // Free up resources
```

**Go (v5)**

The collection also contains a configuration for the generative (RAG) integration:

- Ollama [generative AI integrations](https://docs.weaviate.io/weaviate/model-providers/ollama/generative) for retrieval augmented generation (RAG).

```go
import (
    "context"
    "fmt"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate/entities/models"
)

func main() {
    // Step 1.1: Connect to your local Weaviate instance
    cfg := weaviate.Config{
        Host:   "localhost:8080",
        Scheme: "http",
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 1.2: Create a collection
    classObj := &models.Class{
        Class:      "Movie",
        Vectorizer: "none", // No automatic vectorization since we're providing vectors
        ModuleConfig: map[string]interface{}{
            "generative-ollama": map[string]interface{}{ // Configure the Ollama generative integration
                "apiEndpoint": "http://ollama:11434", // If using Docker you might need: http://host.docker.internal:11434
                "model":       "llama3.2",            // The model to use
            },
        },
    }

    err = client.Schema().ClassCreator().WithClass(classObj).Do(context.Background())
    if err != nil {
        panic(err)
    }

    // Step 1.3: Import three objects
    dataObjects := []struct {
        Properties map[string]interface{}
        Vector     []float32
    }{
        {
            Properties: map[string]interface{}{
                "title":       "The Matrix",
                "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
                "genre":       "Science Fiction",
            },
            Vector: []float32{0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8},
        },
        {
            Properties: map[string]interface{}{
                "title":       "Spirited Away",
                "description": "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
                "genre":       "Animation",
            },
            Vector: []float32{0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9},
        },
        {
            Properties: map[string]interface{}{
                "title":       "The Lord of the Rings: The Fellowship of the Ring",
                "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
                "genre":       "Fantasy",
            },
            Vector: []float32{0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0},
        },
    }

    // Insert the objects with vectors
    objects := make([]*models.Object, len(dataObjects))
    for i, obj := range dataObjects {
        objects[i] = &models.Object{
            Class:      "Movie",
            Properties: obj.Properties,
            Vector:     obj.Vector,
        }
    }

    _, err = client.Batch().ObjectsBatcher().WithObjects(objects...).Do(context.Background())
    if err != nil {
        panic(err)
    }

    fmt.Printf("Imported %d objects with vectors into the Movie collection\n", len(dataObjects))
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.Property;
import io.weaviate.client6.v1.api.collections.VectorConfig;
import io.weaviate.client6.v1.api.collections.Vectors;
import io.weaviate.client6.v1.api.collections.WeaviateObject;
import io.weaviate.client6.v1.api.collections.batch.BatchContext;
import java.util.List;
import java.util.Map;

public class QuickstartLocalCreateVectors {

  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;
    String collectionName = "Movie";

    try {
      // Step 1.1: Connect to your local Weaviate instance
      client = WeaviateClient.connectToLocal();
      // Step 1.2: Create a collection
      client.collections.create(collectionName, col -> col
          // No automatic vectorization since we're providing vectors
          .vectorConfig(VectorConfig.selfProvided())
          // Define properties for the collection
          .properties(Property.text("title"), Property.text("description"),
              Property.text("genre")));

      // Step 1.3: Import three objects
      Map<String, Object> props1 = Map.of("title", "The Matrix", "description",
          "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
          "genre", "Science Fiction");
      // Use primitive float[] for v6
      float[] vector1 =
          new float[] {0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f};

      Map<String, Object> props2 = Map.of("title", "Spirited Away",
          "description",
          "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
          "genre", "Animation");
      float[] vector2 =
          new float[] {0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f};

      Map<String, Object> props3 = Map.of("title",
          "The Lord of the Rings: The Fellowship of the Ring", "description",
          "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
          "genre", "Fantasy");
      float[] vector3 =
          new float[] {0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f};

      // Insert the objects with vectors using server-side batching
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use(collectionName);
      List<WeaviateObject<Map<String, Object>>> objectsToInsert = List.of(
          WeaviateObject.of(v -> v.properties(props1)
              .vectors(Vectors.of(vector1))),
          WeaviateObject.of(v -> v.properties(props2)
              .vectors(Vectors.of(vector2))),
          WeaviateObject.of(v -> v.properties(props3)
              .vectors(Vectors.of(vector3))));

      BatchContext<Map<String, Object>> batch = movies.batch.start();
      // Closing the batch sends the remaining objects and waits for the results
      try (batch) {
        for (WeaviateObject<Map<String, Object>> object : objectsToInsert) {
          batch.add(object);
        }
      }

      if (batch.numberOfErrors() > 0) {
        System.err
            .println("Number of failed imports: " + batch.numberOfErrors());
      } else {
        System.out.println("Imported " + objectsToInsert.size()
            + " objects with vectors into the Movie collection");
      }
    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;

namespace WeaviateProject.Examples
{
    public class QuickstartLocalCreateVectors
    {
public static async Task Run()
{
    string collectionName = "Movie";

    // Step 1.1: Connect to your local Weaviate instance
    var client = await Connect.Local();

    // Step 1.2: Create a collection
    var movies = await client.Collections.Create(
        new CollectionCreateParams
        {
            Name = collectionName,
            // No automatic vectorization since we're providing vectors
            VectorConfig = Configure.Vector("default", v => v.SelfProvided()),
            // Define properties for the collection
            Properties =
            [
                Property.Text("title"),
                Property.Text("description"),
                Property.Text("genre"),
            ],
        }
    );

    // Step 1.3: Import three objects
    var dataToInsert = new List<BatchInsertRequest>
    {
        new(
            new
            {
                title = "The Matrix",
                description = "A computer hacker learns about the true nature of reality and his role in the war against its controllers.",
                genre = "Science Fiction",
            },
            null,
            new float[] { 0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f }
        ),
        new(
            new
            {
                title = "Spirited Away",
                description = "A young girl becomes trapped in a mysterious world of spirits and must find a way to save her parents and return home.",
                genre = "Animation",
            },
            null,
            new float[] { 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f }
        ),
        new(
            new
            {
                title = "The Lord of the Rings: The Fellowship of the Ring",
                description = "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth.",
                genre = "Fantasy",
            },
            null,
            new float[] { 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f }
        ),
    };

    // Insert the objects with vectors using server-side batching
    var insertResponse = await movies.Batch.InsertMany(dataToInsert);
    if (insertResponse.HasErrors)
    {
        Console.WriteLine($"Errors during import: {insertResponse.Errors}");
    }
    else
    {
        Console.WriteLine(
            $"Imported {insertResponse.Count} objects with vectors into the Movie collection"
        );
    }
}
    }
}
```

## Step 2: Semantic (vector) search

> [!TIP]
>
> **For production use**
>
> This step shows vector search on its own. For most applications, start with [hybrid search](https://docs.weaviate.io/weaviate/search/hybrid), which combines vector search with lexical or keyword (BM25) search for a "best of both worlds" performance.

#### Vectorize objects during import

Semantic search finds results based on meaning. This is called `nearText` in Weaviate. The following example searches for 2 objects (*limit*) whose meaning is most similar to that of `sci-fi`.

**Python**

```py
import weaviate
import json

# Step 2.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform a semantic search with NearText
    response = movies.query.near_text(
        query="sci-fi",
        limit=2
    )

    for obj in response.objects:
        print(json.dumps(obj.properties, indent=2))  # Inspect the results
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient } from '@weaviate/node';

// Step 2.1: Connect to your local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal();

// Step 2.2: Use this collection
const movies = client.collections.get('Movie');

// Step 2.3: Perform a semantic search with NearText
const response = await movies.query.nearText(
  'sci-fi',
  {
    limit: 2,
  }
);

for (const obj of response.objects) {
  console.log(JSON.stringify(obj.properties, null, 2)); // Inspect the results
}

await client.close(); // Free up resources
```

**Go (v5)**

```go
import (
    "context"
    "encoding/json"
    "fmt"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql"
)

func main() {
    // Step 1.1: Connect to your local Weaviate instance
    cfg := weaviate.Config{
        Host:   "localhost:8080",
        Scheme: "http",
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 2.2: Perform a semantic search with NearText
    title := graphql.Field{Name: "title"}
    description := graphql.Field{Name: "description"}
    genre := graphql.Field{Name: "genre"}

    nearText := client.GraphQL().NearTextArgBuilder().
        WithConcepts([]string{"sci-fi"})

    result, err := client.GraphQL().Get().
        WithClassName("Movie").
        WithNearText(nearText).
        WithLimit(2).
        WithFields(title, description, genre).
        Do(context.Background())

    if err != nil {
        panic(err)
    }

    // Inspect the results
    if result.Errors != nil {
        fmt.Printf("Error: %v\n", result.Errors)
        return
    }

    data := result.Data["Get"].(map[string]interface{})
    movies := data["Movie"].([]interface{})

    for _, movie := range movies {
        jsonData, err := json.MarshalIndent(movie, "", "  ")
        if err != nil {
            panic(err)
        }
        fmt.Println(string(jsonData))
    }
```

**Go (v6)**

```go
package main

import (
  "context"
  "fmt"

  weaviate "github.com/weaviate/weaviate-go-client/v6"
  "github.com/weaviate/weaviate-go-client/v6/query"
)

func main() {
  ctx := context.Background()

  // Step 2.1: Connect to your local Weaviate instance.
  client, err := weaviate.NewLocal(ctx)
  if err != nil {
    // handle error
    panic(err)
  }
  defer client.Close()

  // Step 2.2: Semantic (vector) search. text2vec-ollama turns the query
  // text into a vector server-side and returns the closest matches.
  movies := client.Collections.Use("Movie")
  response, err := movies.Query.NearText(ctx, query.NearText{
    Concepts: []string{"science fiction movie"},
    Limit:    2,
    ReturnMetadata: query.ReturnMetadata{
      Distance: true,
    },
  })
  if err != nil {
    // handle error
    panic(err)
  }
  for _, obj := range response.Objects {
    fmt.Printf("%v\n", obj.Properties)
    if obj.Metadata.Distance != nil {
      fmt.Printf("distance: %v\n", *obj.Metadata.Distance)
    }
  }
}
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import com.fasterxml.jackson.databind.ObjectMapper; // For pretty-printing JSON

import java.util.Map;

public class QuickstartLocalQueryNearText {
  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;

    try {
      // Step 2.1: Connect to your local Weaviate instance
      client = WeaviateClient.connectToLocal();

      // Step 2.2: Perform a semantic search with NearText
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use("Movie");
      ObjectMapper objectMapper = new ObjectMapper();

      var response = movies.query.nearText("sci-fi",
          q -> q.limit(2).returnProperties("title", "description", "genre"));

      // Inspect the results
      System.out.println("--- Query Results ---");
      for (var obj : response.objects()) {
        System.out.println(objectMapper.writerWithDefaultPrettyPrinter()
            .writeValueAsString(obj.properties()));
      }
    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Weaviate.Client;

namespace WeaviateProject.Examples
{
    public class QuickstartLocalQueryNearText
    {
public static async Task Run()
{
    // Step 2.1: Connect to your local Weaviate instance
    var client = await Connect.Local();

    // Step 2.2: Perform a semantic search with NearText
    var movies = client.Collections.Use("Movie");
    var response = await movies.Query.NearText(
        "sci-fi",
        limit: 2,
        returnProperties: ["title", "description", "genre"]
    );

    // Inspect the results
    Console.WriteLine("--- Query Results ---");
    foreach (var obj in response.Objects)
    {
        Console.WriteLine(
            JsonSerializer.Serialize(
                obj.Properties,
                new JsonSerializerOptions { WriteIndented = true }
            )
        );
    }
}
    }
}
```

#### Import vectors

Semantic search finds results based on meaning. This is called `nearVector` in Weaviate. The following example searches for 2 objects (*limit*) whose vector is most similar to the query vector.

**Python**

```py
import weaviate
import json

# Step 2.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform a vector search with NearVector
    response = movies.query.near_vector(
        near_vector=[0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81], 
        limit=2
    )

    for obj in response.objects:
        print(json.dumps(obj.properties, indent=2))  # Inspect the results
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient } from '@weaviate/node';

// Step 2.1: Connect to your local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal();

// Step 2.2: Use this collection
const movies = client.collections.get('Movie');

// Step 2.3: Perform a vector search with NearVector
const response = await movies.query.nearVector(
  [0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81],
  {
    limit: 2,
  }
);

for (const obj of response.objects) {
  console.log(JSON.stringify(obj.properties, null, 2)); // Inspect the results
}

await client.close(); // Free up resources
```

**Go (v5)**

```go
import (
    "context"
    "encoding/json"
    "fmt"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql"
)

func main() {
    // Step 1.1: Connect to your local Weaviate instance
    cfg := weaviate.Config{
        Host:   "localhost:8080",
        Scheme: "http",
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 2.2: Perform a vector search with NearVector
    title := graphql.Field{Name: "title"}
    description := graphql.Field{Name: "description"}
    genre := graphql.Field{Name: "genre"}

    nearVector := client.GraphQL().NearVectorArgBuilder().
        WithVector([]float32{0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81})

    result, err := client.GraphQL().Get().
        WithClassName("Movie").
        WithNearVector(nearVector).
        WithLimit(2).
        WithFields(title, description, genre).
        Do(context.Background())

    if err != nil {
        panic(err)
    }

    // Inspect the results
    if result.Errors != nil {
        fmt.Printf("Error: %v\n", result.Errors)
        return
    }

    data := result.Data["Get"].(map[string]interface{})
    movies := data["Movie"].([]interface{})

    for _, movie := range movies {
        jsonData, err := json.MarshalIndent(movie, "", "  ")
        if err != nil {
            panic(err)
        }
        fmt.Println(string(jsonData))
    }
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import com.fasterxml.jackson.databind.ObjectMapper; // For pretty-printing JSON

import java.util.Map;

public class QuickstartLocalQueryNearVector {
  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;

    try {
      // Step 2.1: Connect to your local Weaviate instance
      client = WeaviateClient.connectToLocal();

      // Step 2.2: Perform a vector search with NearVector
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use("Movie");
      ObjectMapper objectMapper = new ObjectMapper();

      // Use primitive float[] for v6
      float[] queryVector =
          new float[] {0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f};

      var response = movies.query.nearVector(queryVector,
          q -> q.limit(2).returnProperties("title", "description", "genre"));

      // Inspect the results
      System.out.println("--- Query Results ---");
      for (var obj : response.objects()) {
        System.out.println(objectMapper.writerWithDefaultPrettyPrinter()
            .writeValueAsString(obj.properties()));
      }
    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Text.Json;
using System.Threading.Tasks;
using Weaviate.Client;

namespace WeaviateProject.Examples
{
    public class QuickstartLocalQueryNearVector
    {
public static async Task Run()
{
    // Step 2.1: Connect to your local Weaviate instance
    var client = await Connect.Local();

    // Step 2.2: Perform a vector search with NearVector
    var movies = client.Collections.Use("Movie");

    float[] queryVector = [0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f];

    var response = await movies.Query.NearVector(
        queryVector,
        limit: 2,
        returnProperties: ["title", "description", "genre"]
    );

    // Inspect the results
    Console.WriteLine("--- Query Results ---");
    foreach (var obj in response.Objects)
    {
        Console.WriteLine(
            JsonSerializer.Serialize(
                obj.Properties,
                new JsonSerializerOptions { WriteIndented = true }
            )
        );
    }
}
    }
}
```

**Example response**

```json
{
  "genre": "Science Fiction",
  "title": "The Matrix",
  "description": "A computer hacker learns about the true nature of reality and his role in the war against its controllers."
}
{
  "genre": "Fantasy",
  "title": "The Lord of the Rings: The Fellowship of the Ring",
  "description": "A meek Hobbit and his companions set out on a perilous journey to destroy a powerful ring and save Middle-earth."
}
```

> [!TIP]
>
> **Query Agent**
>
> Try the [Query Agent](https://docs.weaviate.io/query-agent) with a Weaviate Cloud instance. You simply provide a prompt/question in natural language, and the Query Agent takes care of all the needed steps to provide an answer.

## Step 3: Retrieval augmented generation (RAG)

#### Vectorize objects during import

Retrieval augmented generation (RAG), also called generative search, works by prompting a large language model (LLM) with a combination of a *user query* and *data retrieved from a database*.

The following example combines the semantic search for the query `sci-fi` with a prompt to generate a tweet using the Ollama generative model (`generative-ollama`).

**Python**

```py
import weaviate
from weaviate.classes.generate import GenerativeConfig

# Step 2.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform RAG with on NearText results
    response = movies.generate.near_text(
        query="sci-fi",
        limit=1,
        grouped_task="Write a tweet with emojis about this movie.",
        generative_provider=GenerativeConfig.ollama(  # Configure the Ollama generative integration
            api_endpoint="http://ollama:11434",  # If using Docker you might need: http://host.docker.internal:11434
            model="llama3.2",  # The model to use
        ),
    )

    print(response.generative.text)  # Inspect the results
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, generativeParameters } from '@weaviate/node';

// Step 2.1: Connect to your local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal();

// Step 2.2: Use this collection
const movies = client.collections.get('Movie');

// Step 2.3: Perform RAG with on NearText results
const response = await movies.generate.nearText(
  'sci-fi',
  {
    groupedTask: 'Write a tweet with emojis about this movie.',
    config: generativeParameters.ollama({
      apiEndpoint: 'http://ollama:11434',  // If using Docker you might need: http://host.docker.internal:11434
      model: 'llama3.2',                   // The model to use
    }),
  },
  {
    limit: 1,
  }
);

console.log(response.generative); // Inspect the results

await client.close(); // Free up resources
```

**Go (v5)**

```go
import (
    "context"
    "fmt"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql"
)

func main() {
    // Step 2.1: Connect to your local Weaviate instance
    cfg := weaviate.Config{
        Host:   "localhost:8080",
        Scheme: "http",
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 2.2: Perform RAG with NearText results
    title := graphql.Field{Name: "title"}
    description := graphql.Field{Name: "description"}
    genre := graphql.Field{Name: "genre"}

    nearText := client.GraphQL().NearTextArgBuilder().
        WithConcepts([]string{"sci-fi"})

    generate := graphql.NewGenerativeSearch().GroupedResult("Write a tweet with emojis about this movie.")

    result, err := client.GraphQL().Get().
        WithClassName("Movie").
        WithNearText(nearText).
        WithLimit(1).
        WithFields(title, description, genre).
        WithGenerativeSearch(generate).
        Do(context.Background())

    if err != nil {
        panic(err)
    }

    // Inspect the results
    if result.Errors != nil {
        fmt.Printf("Error: %v\n", result.Errors)
        return
    }

    fmt.Printf("%v", result)
```

**Go (v6)**

> [!NOTE]
>
> **Go client `v6`**
>
> Generative (RAG) queries are not yet available in the [`v6` Go client](https://docs.weaviate.io/weaviate/client-libraries/go).

```go
// Coming soon
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.generate.GenerativeProvider;
import java.util.Map;

public class QuickstartLocalQueryNearTextRAG {
  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;

    try {
      // Step 2.1: Connect to your local Weaviate instance
      client = WeaviateClient.connectToLocal();

      // Step 2.2: Perform RAG with nearText results
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use("Movie");

      var response = movies.generate.nearText("sci-fi",
          q -> q.limit(1).returnProperties("title", "description", "genre"),
          // Generative configuration (RAG task)
          g -> g.groupedTask("Write a tweet with emojis about this movie.",
              p -> p.generativeProvider(
                  GenerativeProvider.ollama(o -> o.apiEndpoint("http://ollama:11434")// If using Docker you might need: http://host.docker.internal:11434
                      .model("llama3.2") // The model to use
                  ))));

      // Inspect the results
      System.out.println(response.generative().text());

    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Text.Json;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;
using Weaviate.Client.Models.Generative;

namespace WeaviateProject.Examples
{
    public class QuickstartLocalQueryNearTextRAG
    {
public static async Task Run()
{
    // Step 3.1: Connect to your local Weaviate instance
    var client = await Connect.Local();

    // Step 3.2: Perform RAG with nearText results
    var movies = client.Collections.Use("Movie");

    var response = await movies.Generate.NearText(
        "sci-fi",
        limit: 1,
        returnProperties: ["title", "description", "genre"],
        groupedTask: new GroupedTask("Write a tweet with emojis about this movie."),
        provider: new Providers.Ollama
        {
            ApiEndpoint = "http://ollama:11434", // If using Docker you might need: http://host.docker.internal:11434
            Model = "llama3.2", // The model to use
        }
    );

    // Inspect the results
    Console.WriteLine(JsonSerializer.Serialize(response.Generative.Values));
}
    }
}
```

#### Import vectors

Retrieval augmented generation (RAG), also called generative search, works by prompting a large language model (LLM) with a combination of a *user query* and *data retrieved from a database*.

The following example combines the vector similarity search with a prompt to generate a tweet using the Ollama generative model (`generative-ollama`).

**Python**

```py
import weaviate
from weaviate.classes.generate import GenerativeConfig

# Step 2.1: Connect to your local Weaviate instance
with weaviate.connect_to_local() as client:

    # Step 2.2: Use this collection
    movies = client.collections.use("Movie")

    # Step 2.3: Perform RAG with on NearVector results
    response = movies.generate.near_vector(
        near_vector=[0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81],
        limit=1,
        grouped_task="Write a tweet with emojis about this movie.",
        generative_provider=GenerativeConfig.ollama(  # Configure the Ollama generative integration
            api_endpoint="http://ollama:11434",  # If using Docker you might need: http://host.docker.internal:11434
            model="llama3.2",  # The model to use
        ),
    )

    print(response.generative.text)  # Inspect the results
```

**JavaScript/TypeScript**

```ts
import weaviate, { WeaviateClient, generativeParameters } from '@weaviate/node';

// Step 2.1: Connect to your local Weaviate instance
const client: WeaviateClient = await weaviate.connectToLocal();

// Step 2.2: Use this collection
const movies = client.collections.get('Movie');

// Step 2.3: Perform RAG with on NearVector results
const response = await movies.generate.nearVector(
  [0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81],
  {
    groupedTask: 'Write a tweet with emojis about this movie.',
    config: generativeParameters.ollama({
      apiEndpoint: 'http://ollama:11434',  // If using Docker you might need: http://host.docker.internal:11434
      model: 'llama3.2',                   // The model to use
    }),
  },
  {
    limit: 1,
  }
);

console.log(response.generative); // Inspect the results

await client.close(); // Free up resources
```

**Go (v5)**

```go
import (
    "context"
    "fmt"

    "github.com/weaviate/weaviate-go-client/v5/weaviate"
    "github.com/weaviate/weaviate-go-client/v5/weaviate/graphql"
)

func main() {
    // Step 2.1: Connect to your local Weaviate instance
    cfg := weaviate.Config{
        Host:   "localhost:8080",
        Scheme: "http",
    }
    client, err := weaviate.NewClient(cfg)
    if err != nil {
        panic(err)
    }

    // Step 2.2: Perform RAG with NearText results
    title := graphql.Field{Name: "title"}
    description := graphql.Field{Name: "description"}
    genre := graphql.Field{Name: "genre"}

    nearVector := client.GraphQL().NearVectorArgBuilder().
        WithVector([]float32{0.11, 0.21, 0.31, 0.41, 0.51, 0.61, 0.71, 0.81})

    generate := graphql.NewGenerativeSearch().GroupedResult("Write a tweet with emojis about this movie.")

    result, err := client.GraphQL().Get().
        WithClassName("Movie").
        WithNearVector(nearVector).
        WithLimit(1).
        WithFields(title, description, genre).
        WithGenerativeSearch(generate).
        Do(context.Background())

    if err != nil {
        panic(err)
    }

    // Inspect the results
    if result.Errors != nil {
        fmt.Printf("Error: %v\n", result.Errors)
        return
    }

    fmt.Printf("%v", result)
```

**Java**

```java
import io.weaviate.client6.v1.api.WeaviateClient;
import io.weaviate.client6.v1.api.collections.CollectionHandle;
import io.weaviate.client6.v1.api.collections.generate.GenerativeProvider;
import java.util.Map;

public class QuickstartLocalQueryNearVectorRAG {
  public static void main(String[] args) throws Exception {
    WeaviateClient client = null;

    try {
      // Step 2.1: Connect to your local Weaviate instance
      client = WeaviateClient.connectToLocal();

      // Step 2.2: Perform RAG with NearVector results
      CollectionHandle<Map<String, Object>> movies =
          client.collections.use("Movie");

      // Use primitive float[] for v6
      float[] queryVector =
          new float[] {0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f};

      var response = movies.generate.nearVector(queryVector,
          q -> q.limit(1).returnProperties("title", "description", "genre"),
          // Generative configuration (RAG task)
          g -> g.groupedTask("Write a tweet with emojis about this movie.",
              p -> p.generativeProvider(
                  GenerativeProvider.ollama(o -> o.apiEndpoint("http://ollama:11434")// If using Docker you might need: http://host.docker.internal:11434
                      .model("llama3.2") // The model to use
                  ))));

      // Inspect the results
      // Use .generative() to access the generative result
      System.out.println(response.generative().text());

    } finally {
      if (client != null) {
        client.close(); // Free up resources
      }
    }
  }
}
```

**C#**

```csharp
using System;
using System.Text.Json;
using System.Threading.Tasks;
using Weaviate.Client;
using Weaviate.Client.Models;
using Weaviate.Client.Models.Generative;

namespace WeaviateProject.Examples
{
    public class QuickstartLocalQueryNearVectorRAG
    {
public static async Task Run()
{
    // Step 3.1: Connect to your local Weaviate instance
    var client = await Connect.Local();

    // Step 3.2: Perform RAG with NearVector results
    var movies = client.Collections.Use("Movie");

    float[] queryVector = [0.11f, 0.21f, 0.31f, 0.41f, 0.51f, 0.61f, 0.71f, 0.81f];

    var response = await movies.Generate.NearVector(
        vectors: queryVector,
        limit: 1,
        returnProperties: ["title", "description", "genre"],
        groupedTask: new GroupedTask("Write a tweet with emojis about this movie."),
        provider: new Providers.Ollama
        {
            ApiEndpoint = "http://ollama:11434", // If using Docker you might need: http://host.docker.internal:11434
            Model = "llama3.2", // The model to use
        }
    );

    // Inspect the results
    Console.WriteLine(JsonSerializer.Serialize(response.Generative.Values));
}
    }
}
```

**Example response**

```json
🕶️ Unplug from the system & join Neo's journey 💊🐰

"The Matrix" will blow your mind 🤯 as reality unravels 🌀

Kung-fu, slow-mo & mind-bending sci-fi 🥋🕴️

Are you ready to see how deep the rabbit hole goes? 🔴🔵 #TheMatrix #WakeUp
```

## Next steps

We recommend you check out the following resources to continue learning about Weaviate.

[Quick tour of Weaviate](https://docs.weaviate.io/weaviate/tutorials/quick-tour-of-weaviate): Continue with the Quick tour tutorial – an end-to-end guide that covers important topics like configuring collections, searches, etc.

[Weaviate Academy](https://academy.weaviate.io/): Check out Weaviate Academy – a learning platform centered around AI-native development.

[How-to manuals](https://docs.weaviate.io/weaviate/guides): Quick examples of how to configure, manage and query Weaviate using client libraries.

[Starter guides](https://docs.weaviate.io/weaviate/starter-guides): Guides and tips for new users learning how to use Weaviate.

