I'm currently toying around with Neo4j and cypher, I've been looking around for quite some but I can't find a solution. So here I go :
I have a project where I parse collection of books and I use neo4j to store relations between words, sentences and chapters.
word1-[:NEXTWORD]->word2 -[:NEXTWORD]->word3...
word-[:COMPOSESENTENCE]->sentence-[:COMPOSECHAPTER]->chapter->[:COMPOSEBOOK]->book
Instead of having several relationship between two word I added a counter which I increase every time the words are consecutive
my goal is to write a Cypher query to match a user query like : "once upon" a time ("once upon" being consecutive words)
START
word1=node:node_auto_index(WORD='once'),
word2=node:node_auto_index(WORD='upon')
word3=node:node_auto_index(WORD='a')
word4=node:node_auto_index(WORD='time')
MATCH
word1-[:COMPOSESENTENCE]->sentence-[:COMPOSECHAPTER]->chapter-[:COMPOSEBOOK]->book
word2-[:COMPOSESENTENCE]->sentence,
word3-[:COMPOSESENTENCE]->sentence,
word4-[:COMPOSESENTENCE]->sentence,
word1-[:NEXTWORD]->word2
RETURN
version.VERSIONNAME, book.BOOKNAME, chapter.CHAPTERNUMBER, sentence.SENTENCESTRING;
But when doing so I don't get any result, when checking with neoclipse I can see that such a result exist. So please if anyone has an answer I would be glad to give more information and to try whathever solution you may have. Thanks Matt.