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.

The right way to call algo.similarity.jaccard function through .net

Hello! I have the following query and it's working perfectly:

MATCH (p1:Book{friendlyUrl:"a-modern-witch"})-[r:BOOK_ADDED_TO_CATALOG]->(catalog1:Catalog)
WITH p1, collect(id(catalog1)) AS p1Catalog
MATCH (p2:Book)-[:BOOK_ADDED_TO_CATALOG]->(catalog2:Catalog)
WHERE p1 <> p2
WITH p1, p1Catalog, p2, collect(id(catalog2)) AS p2Catalog
RETURN p1.title AS from,
p2.title AS to,
algo.similarity.jaccard(p1Catalog, p2Catalog) AS similarity

ORDER BY similarity DESC

I want to make this query through my .net core api and here is the code...

 var result = _graphClient.Cypher
        .Match ("(p1:Book{friendlyUrl:'a-modern-witch'})-[r:BOOK_ADDED_TO_CATALOG]->(catalog1:Catalog)")
        .With ("p1, collect(id(catalog1)) AS p1Catalog")
        .Match ("(p2:Book)-[:BOOK_ADDED_TO_CATALOG]->(catalog2:Catalog)")
        .Where ("p1 <> p2")
        .With ("p1, p1Catalog, p2, collect(id(catalog2)) AS p2Catalog")
        .Call ("algo.similarity.jaccard(p1Catalog, p2Catalog)")
        .Yield ("value AS similiarity")
        .Return ((p1, p2, similiarity, p1Catalog, p2Catalog) => new {
          bk = p1.As<BookDetailsDto> (),
          bk2 = p2.As<BookDetailsDto> (),
          similiar = similiarity.As<int> ()
        })
        .Limit (10);

When I call it, I am receiving the following error:

n unhandled exception occurred while processing the request.

NeoException: SyntaxException: Type mismatch: expected List, List or List but was List (line 6, column 30 (offset: 305))
"CALL algo.similarity.jaccard(p1Catalog, p2Catalog)"
^

What's wrong?

2 REPLIES 2

Hi @fanka.bacheva did you still getting errors there?