# K-Nearest-Neighbors in DGraph

**URL:** <https://discuss.dgraph.io/t/k-nearest-neighbors-in-dgraph/8748>\
**Category:** Dgraph\
**Tags:** dgraph, status:accepted, kind:feature, popular, area:querylang:algos\
**Created:** [February 19, 2018, 3:09pm UTC](https://discuss.dgraph.io/t/k-nearest-neighbors-in-dgraph/8748 "2018-02-19T15:09:39Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![diggy](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/diggy/32/3666_2.png) [@diggy](https://discuss.dgraph.io/u/diggy)\
**Post date:** [February 19, 2018, 3:09pm UTC](https://discuss.dgraph.io/t/k-nearest-neighbors-in-dgraph/8748/1 "2018-02-19T15:09:39Z")

</div>

**Moved from GitHub [dgraph/2142](https://github.com/dgraph-io/dgraph/issues/2142)**

_Posted by_ [swagluke](https://github.com/swagluke):

Neo4j has query that does K-Nearest-Neighbors  
BlogPost link:  
[https://neo4j.com/graphgist/movie-recommendations-with-k-nearest-neighbors-and-cosine-similarity#\_view\_your\_nearest\_neighbors](https://neo4j.com/graphgist/movie-recommendations-with-k-nearest-neighbors-and-cosine-similarity#_view_your_nearest_neighbors)

@pawanrawal has read the blogpost and figure the missing part from DGraph is the ability to do a cross product between two vectors.

It would be nice to have documentations or blogpost after this new feature is developed.

---

<div class="post-metadata">

**Author:** ![jgarciax](https://avatars.discourse-cdn.com/v4/letter/j/bbe5ce/32.png) [@jgarciax](https://discuss.dgraph.io/u/jgarciax)\
**Post date:** [September 7, 2020, 8:22am UTC](https://discuss.dgraph.io/t/k-nearest-neighbors-in-dgraph/8748/2 "2020-09-07T08:22:22Z")

</div>

Hello! Is this a feature that has been already developed? Thanks

---

<div class="post-metadata">

**Author:** ![Anurag](https://yyz1.discourse-cdn.com/flex007/user_avatar/discuss.dgraph.io/anurag/32/2599_2.png) [@Anurag](https://discuss.dgraph.io/u/Anurag)\
**Post date:** [September 8, 2020, 7:24pm UTC](https://discuss.dgraph.io/t/k-nearest-neighbors-in-dgraph/8748/4 "2020-09-08T19:24:54Z")

</div>

Nopes, we don’t have this feature yet.

---

<div class="post-metadata">

**Author:** ![EnricoMi](https://avatars.discourse-cdn.com/v4/letter/e/94ad74/32.png) [@EnricoMi](https://discuss.dgraph.io/u/EnricoMi)\
**Post date:** [September 13, 2020, 7:13pm UTC](https://discuss.dgraph.io/t/k-nearest-neighbors-in-dgraph/8748/5 "2020-09-13T19:13:40Z")

</div>

You could load your graph from Dgraph into Spark (using spark-dgraph-connector) and then run an existing k-NN implementation for Spark.
