# Qdrant

## Prerequisites

A [locally running instance of Qdrant](https://qdrant.tech/documentation/quick-start/) or a Qdrant cloud instance.

To get a Qdrant cloud instance:

1. Head to the Clusters section of the [Cloud Dashboard](https://cloud.qdrant.io/overview).
2. Select **Clusters** and then click **+ Create**.

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-630b9c27176080d8e3994dee9265d16c0e31293c%2F2.png?alt=media" alt=""><figcaption></figcaption></figure>

3. Choose your cluster configurations and region.
4. Hit **Create** to provision your cluster.

## Setup

1. Get/Create your **API Key** from the **Data Access Control** section of the [Cloud Dashboard](https://cloud.qdrant.io/overview).
2. Add a new **Qdrant** node on canvas.
3. Create new Qdrant credential using the API Key

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-41e3dad83c446b3f784c4e13c0df5b95d7c95d5e%2F1.png?alt=media" alt="" width="563"><figcaption></figcaption></figure>

4. Enter the required info into the **Qdrant** node:
   * Qdrant server URL
   * Collection name

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-58dc5cd72c1de02b4f013079c2d481f15771f616%2F3.png?alt=media" alt="" width="239"><figcaption></figcaption></figure>

5. **Document** input can be connected with any node under [**Document Loader**](https://docs.flowiseai.com/integrations/langchain/document-loaders) category.
6. **Embeddings** input can be connected with any node under [**Embeddings**](https://docs.flowiseai.com/integrations/langchain/embeddings) category.

## Filtering

Let's say you have different documents upserted, each specified with a unique value under the metadata key `{source}`

<div align="left"><figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-00d83e5ca79746041ab2f4d75559abcca5e107b1%2FScreenshot%202024-03-05%20141551.png?alt=media" alt="" width="563"><figcaption></figcaption></figure> <figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-cd9f5f45f2a6bd82b2074fae769387b1e5004b7d%2FScreenshot%202024-03-05%20141619.png?alt=media" alt="" width="563"><figcaption></figcaption></figure></div>

Then, you want to filter by it. Qdrant supports following [syntax](https://qdrant.tech/documentation/concepts/filtering/#nested-key) when it comes to filtering:

**UI**

<figure><img src="https://823733684-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F00tYLwhz5RyR7fJEhrWy%2Fuploads%2Fgit-blob-3c94a1dc83bf407a373efe2f44cc08a3ffd02bb1%2Fimage%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(1)%20(2)%20(1)%20(1)%20(1).png?alt=media" alt="" width="338"><figcaption></figcaption></figure>

**API**

```json
"overrideConfig": {
    "qdrantFilter": {
        "should": [
            {
                "key": "metadata.source",
                "match": {
                    "value": "apple"
                }
            }
        ]
    }
}
```

## Resources

* [Qdrant documentation](https://qdrant.tech/documentation/)
* [LangChain JS Qdrant](https://js.langchain.com/docs/integrations/vectorstores/qdrant)
* [Qdrant Filter](https://qdrant.tech/documentation/concepts/filtering/#nested-key)
