Datamodel is:
> (A:word {word:'word'})-[:NEXT sentence:<s-order> word:<w-order>]->(B:word)
> (S:Sentence)-[:START]->(A:word)
There's an index on :Word(word)
I've added a bunch of words using the CREATE query. So I know that all words I use in a sentence exist as a node of :word in the Graph. When trying to run a Cypher query to create a sentence in the Neo4j Console, Neo4j returns an error:
Found no solution for block with size 7, Stream() were the selected candidates from the table IDPPlanTable(numberOfPlans=95, largestSolved=6)
Edit I've fiddled around a bit with the query to make it more comprehensible (thanks for the tip!). Some of them are still not working:
MATCH (word8:word {word:'de'}),(word24:word {word:'platen'}),
(word25:word {word:'halen'}),(word26:word {word:'alles'}),
(word27:word {word:'wel'}),(word28:word {word:'weer'}),
(word29:word {word:'voor'}),(word18:word {word:'je'}),
(word30:word {word:'naar'}),(word31:word {word:'boven'}),
(word32:word {word:'als'}),(word33:word {word:'ze'}),
(word3353:word {word:'afspeelt'})
WITH (word8),(word24),(word25),(word26),(word27),(word28),
(word29),(word18),(word30),(word31),(word32),(word33),(word3353)
MERGE (ThisSentence:Sentence {order:3})-[:START]->
(word8)-[nw26:NEXT {sentence:3, word:0}]->
(word24)-[nw27:NEXT {sentence:3, word:1}]->
(word25)-[nw28:NEXT {sentence:3, word:2}]->
(word26)-[nw29:NEXT {sentence:3, word:3}]->
(word27)-[nw30:NEXT {sentence:3, word:4}]->
(word28)-[nw31:NEXT {sentence:3, word:5}]->
(word29)-[nw32:NEXT {sentence:3, word:6}]->
(word18)-[nw33:NEXT {sentence:3, word:7}]->
(word30)-[nw34:NEXT {sentence:3, word:8}]->
(word31)-[nw35:NEXT {sentence:3, word:9}]->
(word32)-[nw36:NEXT {sentence:3, word:10}]->
(word18)-[nw37:NEXT {sentence:3, word:11}]->
(word33)-[nw38:NEXT {sentence:3, word:12}]->(word3353)
WITH ThisSentence MATCH (PrevSentence) WHERE PrevSentence.order=2
MERGE (PrevSentence)-[:NEXT]->(ThisSentence) WITH ThisSentence RETURN ThisSentence
Question: Why is this query failing?
Possible answers I've thought of:
It might something to do with a circular create of relations around word18. As you can see it is used twice in the query, creating two incoming and two outgoing, all being different from eachother:
- 29->18->30
- 32->18->33
How can I prevent this?
Neo4j version is 3.0.6 CE.
WHERE
clause to theMATCH
clause? For exampleMATCH (word0:word {word: 'albums'}), ...
. Performance-wise it should not make a difference (but this one is worth checking withPROFILE
). Also, I think it improves readability. – Gabor SzarnyasWITH ThisSentence MATCH (PrevSentence) WHERE PrevSentence.order=2
, you do not bindPrevSentence
to any specific type (e.g.:Sentence
), only filter for anorder
. This is probably slow to evaluate on a large graph. Another minor suggestion: theWITH
clause after the firstMATCH
is unnecessary. I created an example graph with only the nodes required by your query and it worked fine on an empty database. Can you experiment on an empty database? Maybe on GrapheneDB? – Gabor Szarnyas