# Weaviate Self Query Retriever

This example shows how to use a self query retriever with a [Weaviate](https://weaviate.io/) vector store.

If you haven't already set up Weaviate, please [follow the instructions here](/docs/modules/data_connection/vectorstores/integrations/weaviate).

## Usage

This example shows how to intialize a `SelfQueryRetriever` with a vector store:

import CodeBlock from "@theme/CodeBlock";
import Example from "@examples/retrievers/weaviate_self_query.ts";

<CodeBlock language="typescript">{Example}</CodeBlock>

You can also initialize the retriever with default search parameters that apply in
addition to the generated query:

```typescript
const selfQueryRetriever = await SelfQueryRetriever.fromLLM({
  llm,
  vectorStore,
  documentContents,
  attributeInfo,
  /**
   * We need to use a translator that translates the queries into a
   * filter format that the vector store can understand. LangChain provides one here.
   */
  structuredQueryTranslator: new WeaviateTranslator(),
  searchParams: {
    filter: {
      where: {
        operator: "Equal",
        path: ["type"],
        valueText: "movie",
      },
    },
    mergeFiltersOperator: "or",
  }
});
```

See the [official docs](https://weaviate.io/developers/weaviate/api/graphql/filters) for more on how to construct metadata filters.
