cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

How to get the nth similar nodes in node similarity algorithm

I ran similarity algo (GDS) on a memory graph, this gives me this result (showing the result in the table format):

If I want to return the top similarity pair, I can use limit 1 instead of 3 to get the top result. (Result with the maximum similarity).

But I want to only return the third most similar similarity pair, how can I do that?
Basically, my result should be something like this:

1 ACCEPTED SOLUTION

Hello @abhishekjayant1111

You should have a look at SKIP, in your case:

ORDER BY similarity DESC SKIP 2 LIMIT 1

Regards,
Cobra

View solution in original post

4 REPLIES 4

Hello @abhishekjayant1111

You should have a look at SKIP, in your case:

ORDER BY similarity DESC SKIP 2 LIMIT 1

Regards,
Cobra

Hi @Cobra , thanks for helping out again . This is exactly what I wanted.
However, can you also tell me how to exclude the duplicate similarity pair when I run the node similarity algo. I've shown the duplicate pairs below:

I get these duplicate pairs, how can I get rid of these?
PS: I do now want to use write mode, only want to use stream.

You can modify your WHERE clause like this:

WHERE n1:Adverse_Event
AND n2:Adverse_Event
AND id(n1) > id(n2)

Solved the problem. Thank you so much!