Cypher quotes problem

516 views
Skip to first unread message

Adam Faulconbridge

unread,
Feb 21, 2012, 6:14:03 AM2/21/12
to ne...@googlegroups.com
I am trying to do a Cypher query that uses the advanced Lucene interface to find entries that include spaces. However, I cannot see how to quote this so that it works correctly.

For example purposes, I have a collection of nodes where each node is a book and the title of the book is stored in an index called BookIndex. I want to lookup by parts of the index (e.g. if I have "On the origin of species" I want to be able to find it with "origin of species").

Without spaces in the query, it works fine

START x=node:BookIndex("BookIndex:*origin*")
RETURN x

If I put spaces in the query, I get a null pointer exception - presumably because Leucene is trying to query for "Bookindex:*origin" and seeing "of" and "species" as extra parameters.

START x=node:BookIndex("BookIndex:*origin of species*")
RETURN x

I have tried various combinations of single and double quotes, backticks, and escaping without any joy. It seems the the problem is that both Leucene and Cypher use only double quotes to delimit strings, and Cypher can't escape them (yet). Backticks (`) can be used for properties in Cypher, but not for function parameters.

For the moment, I am replacing spaces with underscores in all indexed fields but it would be nice if this was not needed.

Using neo4 v1.6 from Python v2.7.2 on 64-Bit Xubuntu.

Michael Hunger

unread,
Feb 21, 2012, 6:24:35 AM2/21/12
to ne...@googlegroups.com
Wildcard matches and spaces in query strings don't work in lucene at all.

Did you also try to:

#1 node:BookIndex('BookIndex:"origin of species"') (single quotes for the cypher parameter, double quotes for lucene
#2 use a parameter so that you don't have to escape it in your literal query
node:BookIndex({index_query}) and "index_query" -> "BookIndex:\"origin of species\""

HTH

Michael

Reply all
Reply to author
Forward
0 new messages