1

I have a query like I wrote below. I couldn't solve the error I gave below even after a lot of effort. I encounter this error when I do any sorting operation. But not always, in specific cases. I think sometimes my query doesn't return Double(NaN) values most of the time, so I rarely encounter this error.

MATCH (news:News {newsId: "/infografik/jurnalist/turkiye-sma-hastaligi-icin-yeni-adimlar-atiyor-26685"})
WITH news
WHERE news.cleanTitle IS NOT NULL

MATCH (otherNews:News {category: news.category})
WHERE news <> otherNews AND otherNews.cleanTitle IS NOT NULL

WITH otherNews,
     apoc.text.sorensenDiceSimilarity(news.cleanTitle, otherNews.cleanTitle) AS sorensen
ORDER BY sorensen DESC
LIMIT 10
RETURN otherNews.title, sorensen, otherNews.category;

Error:

Neo.ClientError.Statement.TypeError Wrong argument type: Can't coerce Double(NaN) to String

I want to see results sorted correctly. When I don't sort, I can see the results without any problems. But I need the sorted version. I tried converting the Sorensen value to string, eliminating Null or NaN values. But I was not successful.

4
  • Have you tried: apoc.text.sorensenDiceSimilarity(toString(news.cleanTitle), toString(otherNews.cleanTitle)) ? Commented Feb 6 at 11:50
  • I tried this but I think I made a mistake in my previous attempt. It worked very correctly now. Thank you for your help. Commented Feb 6 at 12:07
  • Can you share what the "mistake" was, in case it would be helpful to others?
    – cybersam
    Commented Feb 6 at 20:34
  • 1
    I tried to use the toString function like this, my mistake was here: toString(apoc.text.sorensenDiceSimilarity(news.cleanTitle, otherNews.cleanTitle)) @cybersam Commented Feb 7 at 8:19

1 Answer 1

0

Migrating OP's solution to an answer:

I saw that the error was resolved when I placed the "LIMIT 10" line above the "RETURN" line. But this time the results were very inconsistent. If I don't set any limits, I still encounter the same error. I can increase my limit amount up to a certain number >depending on the data I use. As I get closer to the limit I can reach, the accuracy of >my returned data increases. How can I overcome this problem?

Fix: change to this piece of code solved my problem. Thanks to Finbar Good's comment.

apoc.text.sorensenDiceSimilarity(toString(news.cleanTitle), toString(otherNews.cleanTitle))

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.