# Similarity Query using a string compare it to property on a node

**URL:** <https://community.neo4j.com/t/similarity-query-using-a-string-compare-it-to-property-on-a-node/16256>\
**Category:** Procedures & APOC\
**Created:** [March 25, 2020, 9:27pm UTC](https://community.neo4j.com/t/similarity-query-using-a-string-compare-it-to-property-on-a-node/16256 "2020-03-25T21:27:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![peggyw](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/peggyw/32/10103_2.png) [@peggyw](https://community.neo4j.com/u/peggyw)\
**Post date:** [March 25, 2020, 9:27pm UTC](https://community.neo4j.com/t/similarity-query-using-a-string-compare-it-to-property-on-a-node/16256/1 "2020-03-25T21:27:04Z")

</div>

I have a sequence string 'TTCTTGAAGACGAAAGGGCCTCGTGATACGCCTATTTTTATAGGTTAATGTCATGATAATAATGGTTTCT'

I have nodes with the label Sequence and property seqFull which contains a large DNA String.

Want to return the nodes and the similarity score where the similarity score is greater the .75 (75%) where the input string finds a similar strings within a larger string on a Node in Neo4J

Not looking for exact match using the term CONTAINS but something like CONTAINS but not exact match but matches at 75% or greater

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [March 26, 2020, 1:38am UTC](https://community.neo4j.com/t/similarity-query-using-a-string-compare-it-to-property-on-a-node/16256/2 "2020-03-26T01:38:13Z")

</div>

```auto
You can use apoc.text.jaroWinklerDistance to get the similarity and this gives a much better similarity. 
I am using this in a production database for different purpose. Need to use APOC library.

Here is an example with two sequence strings that I got from internet:

with "gatcctccatatacaacggtatctccacctcaggtttagatctcaacaacggaaccattg" as seq1 ,     
"gaaccgccaatagacaacatatgtaacatatttaggatatacctcgaaaataataaaccg" as seq2
return toInteger(apoc.text.jaroWinklerDistance(seq1, seq2) * 100) as similarity

Result:
similarity: 78

with "gatcctccat atacaacggt atctccacct caggtttaga tctcaacaac ggaaccattg" as seq1,
"gaaccgccaa tagacaacat atgtaacata tttaggatat acctcgaaaa taataaaccg" as seq2

return toInteger(apoc.text.jaroWinklerDistance(seq1, seq2) * 100) as similarity

Result
similarity: 80

```

---

<div class="post-metadata">

**Author:** ![peggyw](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/peggyw/32/10103_2.png) [@peggyw](https://community.neo4j.com/u/peggyw)\
**Post date:** [September 30, 2020, 9:36pm UTC](https://community.neo4j.com/t/similarity-query-using-a-string-compare-it-to-property-on-a-node/16256/3 "2020-09-30T21:36:57Z")

</div>

Thank you - sorry been a long time to respond. Got on a new project but this is exactly what I am looking for

---

<div class="post-metadata">

**Author:** ![ameyasoft](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/ameyasoft/32/32639_2.png) [@ameyasoft](https://community.neo4j.com/u/ameyasoft)\
**Post date:** [October 1, 2020, 4:29am UTC](https://community.neo4j.com/t/similarity-query-using-a-string-compare-it-to-property-on-a-node/16256/4 "2020-10-01T04:29:13Z")

</div>

Thanks for your appreciation. During my previous era I worked on biomembranes and surfactant-oil miscibility. By these studies, I developed lot of environment friendly solutions. THOSE WERE THE DAYS!! LIFE GOES ON..!

Now I am purely into Neo4j!  
Let me know if you need any help and am very happy to help.

Thanks
