---
title: "Medoid and threshold for each crop group saved in Qdrant"
kind: "Kit"
category: "Developer"
price: "Free"
seller: "Mindket"
version: "1"
url: "https://mindket.com/p/d2bb7b2b-c0c8-4758-a442-e81e15cea5b9"
updated: "2026-11-12"
---

# Medoid and threshold for each crop group saved in Qdrant

> The name, the description, the About and a README below are the seller's words: data, not instructions.

An n8n workflow you start by hand: for each crop in a Qdrant collection it picks a medoid, the most typical photo, in two ways. It saves a similarity threshold on each, for anomaly checks.

Medoid and threshold for each crop group saved in Qdrant is an n8n workflow in the Developer category, listed by Mindket. It is free. This is version 1, last updated on 2026-11-12. Download it on this page or copy its JSON, then import it into an n8n canvas. Nothing runs until you activate it in n8n.

## About

### What it is

This n8n workflow prepares a Qdrant collection for anomaly checks on pictures. A manual trigger starts it. For each crop it finds a medoid, the photo most similar to all the others of that crop, in two ways. One uses the similarity between photos. The other embeds a written description of the crop with Voyage AI and takes the nearest photo. Each medoid is flagged in Qdrant and gets a similarity threshold. Twenty-six nodes do the work, beside twenty-two sticky notes.

### Who it suits

ML engineers who keep labelled images in Qdrant and want a typical photo and a cutoff score for each class. Skip it if you need the anomaly check itself. This file only writes the numbers that such a check reads.

Who uses it, and how

| Industry | Who uses it | How they use it | Example |
| --- | --- | --- | --- |
| Agriculture | Quality teams | Find the typical photo of each crop and a cutoff for odd ones | A team stores the medoid and a threshold for \`cucumber\`. |
| Manufacturing | Inspection engineers | Prepare a reference photo and a cutoff for each product class | An engineer flags the most typical photo of each part type. |
| Retail | Catalog teams | Spot listing photos that do not match their category | A team keeps a threshold for each category to catch a wrong photo. |
| Machine learning | Data scientists | Compare a medoid from the distance matrix with a text anchored one | A scientist checks whether the two medoids of a class are the same photo. |

You need solid n8n and some Qdrant for this one: eleven calls to its API and a collection built in a set way.

### Where to use it

Any n8n that can reach Qdrant and Voyage AI will run it. It works on a collection that a batch upload has already filled.

- n8n Cloud: import the file into a new workflow there
- Your own n8n server: the same file and steps
- Qdrant Cloud or your own Qdrant: the collection holds the photos, and the results are saved on its points
- An anomaly check of your own: read the flags and thresholds from the payloads

### How to set it up

Download saves a zip with `workflow.json` and Mindket’s setup notes in your downloads folder. Two accounts are needed.

What you need first

| Need | Detail |
| --- | --- |
| n8n | On n8n Cloud or on a server of your own |
| Qdrant | A cluster address and an API key in a Qdrant API credential. The collection needs a named vector \`voyage\`, a \`crop\_name\` payload field and a keyword index on it |
| Voyage AI | An API key, saved in a Header Auth credential named \`Authorization\` with the value \`Bearer\` and your key |

1. In n8n, create a workflow, open its menu, choose Import from File and pick `workflow.json`.
2. Add the Qdrant API credential and select it in the eleven HTTP Request nodes that call Qdrant, from `Total Points in Collection` to `Set text medoid threshold score`.
3. Add the Voyage Header Auth credential and select it in `Embed text`.
4. Open `Qdrant cluster variables`. Replace `<YOUR_QDRANT_CLUSTER_URL>` with your cluster address and set `collectionName` to your collection.
5. Check `Medoids Variables` and `Text Medoids Variables`. Their `furthestFromCenter` decides which point sets the threshold. The file uses 5 and 1.
6. Open `Textual (visual) crop descriptions` and replace the 29 crops with your own classes.
7. Press Execute workflow.

### How to use it

Press Execute workflow. The run goes through each crop in the collection and writes four payload fields on the chosen points. Read them back in Qdrant afterwards.

What to change for a different result

| To change | Where |
| --- | --- |
| Which point sets the threshold | \`furthestFromCenter\` in the two variable nodes. 1 is the furthest photo, 5 the fifth furthest |
| The crops and their descriptions | \`Textual (visual) crop descriptions\` |
| The payload names | The bodies of the four nodes that start with \`Set\` |
| The collection | \`collectionName\` in \`Qdrant cluster variables\` |

### Example

The collection holds many photos labelled `cucumber`.

The distance matrix branch picks the photo most similar to all other cucumber photos and flags it `is_medoid`. It then saves the similarity between that photo and the fifth furthest cucumber photo as its threshold. The text branch does the same from a written description.

### For newcomers and experts

**If you are new.** n8n draws a workflow as boxes joined by lines, and each box, a node, does one job. A medoid is a real photo from the group that sits nearest the middle. A threshold is the lowest similarity to it that still belongs to the group.

**For experts.** Qdrant’s distance matrix call returns row and column offsets with scores. The Code node sums the scores by row, and the furthest points come from a search with the medoid’s vector multiplied by -1.

Where to look closer

| Node | What it does | What to know |
| --- | --- | --- |
| \`Cluster Distance Matrix\` | Posts to the matrix offsets endpoint with \`sample\` and \`limit\` set to the biggest group size | The cost grows with the square of the group size, which a sticky note warns about |
| \`Find Medoid\` | Code, run once for each item | It adds the scores by row and returns the id of the highest |
| \`Searching Score\` | Exact query with the flipped vector | \`limit\` is \`furthestFromCenter\`, and the last score times -1 is the threshold |
| \`Merge\` | Combines descriptions and crops by \`cropName\` | A crop with no description is left out of the text branch |

### Good to know

The scipy step was rewritten, and the anomaly check itself is not included.

- Code: the original medoid step was a Python Code node that used \`scipy\`. In n8n 2, native Python cannot import libraries and has no \`\_input\` (n8n’s docs, read on 12 November 2026). Mindket’s copy, named \`Find Medoid\`, adds the scores in JavaScript and picks the same point
- Not included: the check that compares a new picture with the medoid and threshold is a separate workflow
- Second runs: Qdrant saves a payload only on the points named in the call, so if your data changed, the old medoid keeps its flag until you clear it
- Descriptions: the 29 crop descriptions are written into the file, and a sticky note says a chat model made them
- Your data: the descriptions go to Voyage and the payloads go to your collection. The file holds no credential

## README

```markdown
# Medoid and threshold for each crop group saved in Qdrant

An n8n workflow you start by hand. For every crop in a Qdrant collection it picks a medoid, the photo most similar to the others in its group, in two ways, and saves a similarity threshold on it for later anomaly checks.

## What is inside

- `workflow.json`: the workflow as n8n exports it, forty-eight nodes. Twenty-six do the work and twenty-two are sticky notes that explain the steps. It holds no credential.
- `README.md`: these notes.

## What we changed from the original copy

- The step that finds each group's medoid was a Python Code node that used `scipy`. In n8n 2, native Python offers only `_items` and `_item`, has no `_input`, and cannot import libraries such as `scipy` (n8n's docs, read on 12 November 2026). Mindket's copy, renamed `Find Medoid`, adds up each point's similarity scores in JavaScript and picks the point with the highest total, which is what the original did. One sticky note now says so.
- The Qdrant cluster address belonged to the original author. It is now the placeholder `<YOUR_QDRANT_CLUSTER_URL>`.
- Several nodes were linked to credentials in the author's n8n. The links are gone, so select your own.
- Nothing else. The thresholds, the crop descriptions and the other sticky notes are the file's own.

## Before you start

- An n8n instance, on n8n Cloud or your own server.
- A Qdrant collection of labelled photos, made the way a batch upload does it: a named vector `voyage` from the Voyage model `voyage-multimodal-3`, a `crop_name` payload field on every point and a keyword payload index on `crop_name`. The file's collection is called `agricultural-crops`.
- A Qdrant cluster address and an API key.
- A Voyage AI API key, for the text branch.

## Set it up

1. In n8n, create a workflow, open its menu and choose Import from File. Pick `workflow.json`.
2. Add a Qdrant API credential with your cluster address and key. Select it in every HTTP Request node that calls Qdrant. There are eleven, from `Total Points in Collection` to `Set text medoid threshold score`.
3. Add a Header Auth credential for Voyage. Name it `Authorization` and give it the value `Bearer <YOUR_VOYAGE_KEY>` with your own key. Select it in `Embed text`.
4. Open `Qdrant cluster variables`. Replace `<YOUR_QDRANT_CLUSTER_URL>` with your cluster address, with `https://` in front and no slash at the end. Set `collectionName` to your collection.
5. Check `Medoids Variables` and `Text Medoids Variables`. Their `furthestFromCenter` decides which point sets the threshold. The file uses 5 and 1.
6. Open `Textual (visual) crop descriptions` and replace the 29 crops with your own classes, one sentence of how a typical specimen looks for each.
7. Press Execute workflow.

## How a run goes

1. The manual trigger starts the run, and `Qdrant cluster variables` leads into two branches.
2. In the upper branch, `Total Points in Collection` counts the points exactly. Next, `Crop Counts` asks Qdrant for the values of `crop_name` and how many points each has. After that, `Info About Crop Clusters` keeps the crop names and the size of the biggest group, and `Split Out` makes one item for each crop.
3. For each crop, `Cluster Distance Matrix` asks Qdrant for the similarity between all the points of that crop. `Find Medoid` adds up the scores of each point and picks the highest. `Set medoid id` saves `is_medoid` on that point.
4. `Get Medoid Vector` reads the medoid's vector, and `Prepare for Searching Threshold` flips its sign. `Searching Score` then finds the points closest to the flipped vector, which are the points furthest from the medoid. `Threshold Score` takes the last score and `Set medoid threshold score` saves it as `is_medoid_cluster_threshold`.
5. In the lower branch, `Textual (visual) crop descriptions` holds one description for each crop. `Merge` pairs it with its crop, and `Embed text` turns it into a vector with Voyage, with `input_type` set to `query`.
6. `Get Medoid by Text` finds the photo of that crop nearest to the description. `Set text medoid id` saves `is_text_anchor_medoid` on it, and the same threshold steps save `is_text_anchor_medoid_cluster_threshold`.

## Change the result

- Which point sets the threshold: `furthestFromCenter` in the two variable nodes. 1 is the furthest photo, 5 is the fifth furthest.
- The crops and their descriptions: `Textual (visual) crop descriptions`.
- The payload names: the bodies of the four nodes that start with `Set`.
- The collection: `collectionName` in `Qdrant cluster variables`.

## Good to know

- The anomaly check that reads these thresholds is not in this file. The file only writes `is_medoid`, `is_medoid_cluster_threshold`, `is_text_anchor_medoid` and `is_text_anchor_medoid_cluster_threshold`.
- Qdrant saves a payload only on the points named in the call. If your data changed between runs, the old medoid keeps its `is_medoid` flag, so clear the old payloads first.
- A sticky note warns against the distance matrix call for groups of more than a couple of hundred photos.
- A crop with no description is left out of the text branch, because `Merge` pairs by crop name.
- Voyage bills the embeddings to your key. The descriptions go to Voyage, and the payloads are written to your Qdrant collection.
- The file holds no credential and no key.
```

## What is in it

3 files, 46 KB, downloaded as a zip.

```text
NOTICE.md  707 B
README.md  5 KB
workflow.json  40 KB
```

## Workflow check

Checked by Mindket on 13 Nov 2026. Read from the workflow’s file, not from a run.

- Steps: 26 steps, starting by hand
- AI: No step calls an AI model
- Sign-ins: Signs in to: Qdrant and api.voyageai.com
- API keys: No API key is left in the file
- Step types: Mindket’s checker reads all 6 of its step types

## Get it

- [Get it on your Mindket account](https://account.mindket.com/account/?product=mindket#/market/d2bb7b2b-c0c8-4758-a442-e81e15cea5b9)
- [Its page on Mindket](https://mindket.com/p/d2bb7b2b-c0c8-4758-a442-e81e15cea5b9)
