# Find similar rows

Model / similarity

row-to-row distance, nearest-neighbour search, vector search

Page: <https://meridian.online/operations/find-similar-rows>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

cosine similarity between vectors

```sql
CREATE TEMP TABLE result AS
WITH v(id, e) AS (VALUES ('a', [1.0, 0.0, 1.0]), ('b', [0.9, 0.1, 1.0]), ('c', [0.0, 1.0, 0.0]))
SELECT x.id, y.id AS other, round(list_cosine_similarity(x.e, y.e), 4) AS cos FROM v x JOIN v y ON x.id < y.id ORDER BY cos DESC;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT max(cos) FILTER (WHERE id = 'a' AND other = 'c') = 0 AND arg_max(other, cos) FILTER (WHERE id = 'a') = 'b' FROM result)) THEN 'as expected' ELSE error('the nearest vector to a is not b, or two orthogonal vectors do not score 0') END AS verdict;
```

The statement builds its own data.

It needs nothing installed beyond DuckDB itself.

## Variants

- [Measure the distance between two values](https://meridian.online/operations/find-similar-rows/measure-distance-between-values): Compute a distance, similarity or inner product between two vectors or strings in the same row.
- Build a vector index: Build an index such as HNSW or a space-partitioning tree that speeds nearest-neighbour search.
- Learn a distance metric: Learn a transform from labelled rows that makes nearest-neighbour matching more accurate.
- Drop near-duplicate rows: Remove rows whose embeddings are within a similarity threshold of another row.
- Find the nearest neighbours: For each query row or vector, return the k closest rows, or those within a distance.
- [Compute pairwise distances](https://meridian.online/operations/find-similar-rows/compute-pairwise-distances): Compute the distance or similarity between every pair of rows, as a matrix or a table of pairs.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Alteryx Designer: [`AB Controls`](https://help.alteryx.com/current/en/designer/tools/ab-testing/ab-controls-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Find Nearest Neighbors`](https://help.alteryx.com/current/en/designer/tools/predictive-grouping/find-nearest-neighbors-tool.html) (read 2026-09-27)
- Duckle: [`Semantic Dedupe`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Duckle: [`Vector Similarity Search`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- Apache Hop: [`pgvector search`](https://hop.apache.org/manual/next/pipeline/transforms/pgvector-search.html) (read 2026-09-27)
- Ibis: [`Levenshtein`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/strings.py) (read 2026-09-27)
- KNIME Analytics Platform: [`KNIME Distance Matrix (extension)`](https://api.hub.knime.com/extensions/org.knime.features.distmatrix) (read 2026-09-27)
- KNIME Analytics Platform: [`Random Forest Distance`](https://api.hub.knime.com/nodes/*w_GCZJ7eZW2G8We-?details=full) (read 2026-09-27)
- mlpack: [`Distances`](https://www.mlpack.org/doc/user/core.html) (read 2026-09-27)
- mlpack: [`KFN`](https://www.mlpack.org/doc/user/modeling.html) (read 2026-09-27)
- mlpack: [`KNN`](https://www.mlpack.org/doc/user/modeling.html) (read 2026-09-27)
- mlpack: [`Kernels`](https://www.mlpack.org/doc/user/core.html) (read 2026-09-27)
- mlpack: [`LMNN`](https://www.mlpack.org/doc/user/transformations.html) (read 2026-09-27)
- mlpack: [`NCA`](https://www.mlpack.org/doc/user/transformations.html) (read 2026-09-27)
- mlpack: [`Trees`](https://www.mlpack.org/doc/index.html) (read 2026-09-27)
- mlpack: [`mlpack_approx_kfn`](https://www.mlpack.org/doc/user/bindings/cli.html) (read 2026-09-27)
- mlpack: [`mlpack_fastmks`](https://www.mlpack.org/doc/user/bindings/cli.html) (read 2026-09-27)
- mlpack: [`mlpack_krann`](https://www.mlpack.org/doc/user/bindings/cli.html) (read 2026-09-27)
- mlpack: [`mlpack_lsh`](https://www.mlpack.org/doc/user/bindings/cli.html) (read 2026-09-27)
- mlpack: [`mlpack_range_search`](https://www.mlpack.org/doc/user/bindings/cli.html) (read 2026-09-27)
- RapidMiner Studio: [`Cross Distances`](https://docs.rapidminer.com/latest/studio/operators/modeling/similarities/cross_distances.html) (read 2026-09-27)
- RapidMiner Studio: [`Data to Similarity`](https://docs.rapidminer.com/latest/studio/operators/modeling/similarities/data_to_similarity.html) (read 2026-09-27)
- RapidMiner Studio: [`Data to Similarity Data`](https://docs.rapidminer.com/latest/studio/operators/modeling/similarities/data_to_similarity_data.html) (read 2026-09-27)
- RapidMiner Studio: [`Retrieve Documents (Milvus)`](https://docs.rapidminer.com/latest/studio/operators/extensions/Generative%20Models/Vector%20Stores/Milvus/retrieve_documents_milvus.html) (read 2026-09-27)
- RapidMiner Studio: [`Retrieve Documents (Qdrant)`](https://docs.rapidminer.com/latest/studio/operators/extensions/Generative%20Models/Vector%20Stores/Qdrant/retrieve_documents_qdrant.html) (read 2026-09-27)
- RapidMiner Studio: [`Similarity to Data`](https://docs.rapidminer.com/latest/studio/operators/modeling/similarities/similarity_to_data.html) (read 2026-09-27)
- Apache SeaTunnel: [`Vector Functions`](https://seatunnel.apache.org/docs/2.3.13/transforms/sql-functions) (read 2026-09-27)
- subtoken: [`HNSW index`](https://duckdb.org/docs/current/core_extensions/vss.html) (read 2026-09-27)
- subtoken: [`array_cosine_distance`](https://duckdb.org/docs/current/sql/functions/array.html) (read 2026-09-27)
- subtoken: [`array_cosine_similarity`](https://duckdb.org/docs/current/sql/functions/array.html) (read 2026-09-27)
- subtoken: [`array_distance`](https://duckdb.org/docs/current/sql/functions/array.html) (read 2026-09-27)
- subtoken: [`array_inner_product`](https://duckdb.org/docs/current/sql/functions/array.html) (read 2026-09-27)
- subtoken: [`array_negative_inner_product`](https://duckdb.org/docs/current/sql/functions/array.html) (read 2026-09-27)
- subtoken: [`hnsw_index_scan`](https://duckdb.org/docs/current/core_extensions/vss.html) (read 2026-09-27)
- subtoken: [`list_cosine_distance`](https://duckdb.org/docs/current/sql/functions/list.html) (read 2026-09-27)
- subtoken: [`list_cosine_similarity`](https://duckdb.org/docs/current/sql/functions/list.html) (read 2026-09-27)
- subtoken: [`list_distance`](https://duckdb.org/docs/current/sql/functions/list.html) (read 2026-09-27)
- subtoken: [`list_inner_product`](https://duckdb.org/docs/current/sql/functions/list.html) (read 2026-09-27)
- subtoken: [`list_negative_inner_product`](https://duckdb.org/docs/current/sql/functions/list.html) (read 2026-09-27)
- subtoken: [`vss_join`](https://duckdb.org/docs/current/core_extensions/vss.html) (read 2026-09-27)
- subtoken: [`vss_match`](https://duckdb.org/docs/current/core_extensions/vss.html) (read 2026-09-27)
- Talend: [`tSemanticMatch`](https://help.qlik.com/talend/en-US/components/8.0/semantic/semantic-component) (read 2026-09-27)
- Yggdrasil Decision Forests: [`distance`](https://github.com/google/yggdrasil-decision-forests/blob/0a54b57c95ff0cf42ecf0310ace0513a4f32cb65/yggdrasil_decision_forests/port/python/ydf/model/decision_forest_model/decision_forest_model.py) (read 2026-09-27)
