maurice1408 / Neodash

Repo for Neodash
0 stars 0 forks source link

Return specific connection #5

Open AnneGriff opened 4 days ago

AnneGriff commented 4 days ago

For some relationships where there are multiple short paths, I don’t get the one I want. The first query below returns a common visitor, Fabricius, Johan Christian

WHAT I WANT TO SHOW is that Monson 'Created' the 'Monson Bengal Insect Collection' and the 'Monson Bengal Insect Collection' was 'Bequeathed_to' Ann Lee see query 2. I don’t mind writing a specific query for each of these as there are many similar instances - but does it take more processing time? and more importantly, the second query doesn’t work.

QUERY 1

//
// Lee, Ann
// TO
// Monson, Lady Anne Pair 11
//
OPTIONAL MATCH (p11fa:Person), (p11fb:Person),
r11fb = shortestPath((p11fb)-[*..3]-(p11fa))
WHERE p11fa.name = "Monson, Lady Anne" and
p11fb.name = "Lee, Ann"
return r11fb

QUERY 2

// Lee, Ann
// TO
// Monson, Lady Anne Pair 11
//
OPTIONAL MATCH (p11fa:Person), (p11fb:Person), (o11f:Object),
(p11fa)-[r11fa:Created]->(o11f),
(o11f)-[r11fb:Bequeathed_to]->(p11fb)
WHERE p11fa.name = "Monson, Lady Anne" and
p11fb.name = "Lee, Ann" and
o11f = "Monson Bengal Insect Collection"

return r11fa, r11fb
maurice1408 commented 3 days ago

Minor point... use markdown to make these easier to read. If you edit the above issue you will see the very little markdown I had to add to make this readable?

image
maurice1408 commented 3 days ago

So are you saying "QUERY 1" works as expected? It certainly does for me (running though Browser against desktop)

image
AnneGriff commented 3 days ago

Yes it does work, but it isn’t the result I want - it isn’t neo4j’s fault it just returns the first thing. I want to return that specific relationship which is actually more personal. There will be a few like that.

On 6 Oct 2024, at 16:36, Maurice Hickey @.***> wrote:

So are you saying "QUERY 1" works as expected? It certainly does for me (running though Browser against desktop)

image.png (view on web) https://github.com/user-attachments/assets/e55ab8e8-6e83-4032-add8-c873bcccef01 — Reply to this email directly, view it on GitHub https://github.com/maurice1408/Neodash/issues/5#issuecomment-2395481508, or unsubscribe https://github.com/notifications/unsubscribe-auth/BLSIOG5ANQGVLYTIKDISMIDZ2FKGTAVCNFSM6AAAAABPOM3FGWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJVGQ4DCNJQHA. You are receiving this because you authored the thread.

t. 07788 518 480 www.annegriffiths.com Insta @anne_griffiths_com

maurice1408 commented 3 days ago

But what result do you want / expect?

maurice1408 commented 3 days ago

QUERY 2

This works...

OPTIONAL MATCH 
(p11fa:Person)-[r11fa:Created]->(o11f:Object)
WHERE p11fa.name = "Monson, Lady Anne" and o11f.name = "Monson Bengal Insect Collection"
with p11fa, o11f, r11fa
match (o11f)-[r11fb]->(p11fb:Person)
// p11fb.name = "Lee, Ann" and
return p11fa, o11f, r11fa, p11fb, r11fb

a) (p11fa:Person), (p11fb:Person), (o11f:Object), is very innefficient, will read every Person and Object b) your where on o11f = should be `o11f.name ='

AnneGriff commented 3 days ago

Sorry I didn't see that Query 1 worked for you and gave Insect Collection - it didn't for me. Running on my browser gives

image

Can you write it so that p11fb points to Lee, Ann? I think this will return any relationship to the Monson Insect Collection won't it? It doesn't matter on this query as there is only one relationship but on others it may not be so simple and I will want to define the second relationship and the second person. Sorry to be thick