---
title: total_neighbors
url: https://nexyron.tech/docs/cypher/functions/vector-and-similarity/total-neighbors
description: Counts the union size of two list as set inputs. It is documented separately because similarity orientation, vector dimensions, and set semantics directly affect ranking and interp
---

# total_neighbors

## Generic Description

Counts the union size of two list-as-set inputs. It is documented separately because similarity orientation, vector dimensions, and set semantics directly affect ranking and interpretation.

Simple example:

```cypher
RETURN total_neighbors(['a', 'b'], ['b', 'c']) AS value
```

## Consumer-Level Explanation

Use it as the denominator context for overlap-style comparisons. Prefer this function when symbolic graph filters and similarity evidence should remain in one auditable Cypher pipeline.

## More Detailed Explanation

`total_neighbors` keeps similarity scoring in the same Cypher pipeline as symbolic graph filters and document metadata checks. That lets a query combine labels, relationships, time filters, and embedding or set overlap scores without asking a client to reconcile separate result sets.

## Advanced Example

This example applies `total_neighbors` after symbolic graph filtering, which keeps hybrid retrieval constraints and similarity scoring in one visible pipeline.

```cypher
MATCH (d:Document)
WITH d, keys(properties(d.metadata)) AS metadata_keys
RETURN d.title AS document,
       total_neighbors(metadata_keys, ['kind', 'lang', 'owner']) AS compared_metadata_fields
ORDER BY compared_metadata_fields DESC
```

## Real Use Cases

-   semantic ranking over embedded documents after graph/time filtering
-   link-prediction features based on shared neighbors or metadata overlap
-   hybrid retrieval where symbolic constraints and vector scores are both visible

## Real Limitations And Tradeoffs

-   vector functions require compatible dimensions and meaningful embedding spaces
-   set-similarity functions treat lists as sets and may ignore duplicate frequency
-   a high similarity score is evidence, not proof of domain equivalence
