Cypher queries & special characters

2,589 views
Skip to first unread message

Razvan Tanase

unread,
May 22, 2012, 8:20:18 PM5/22/12
to Neo4j
Hi,

We have nodes that contain properties with special characters like
colon, full stop.
How can we use those properties in cypher queries, in start/where
clauses? I tried to escaping them and it didn't work.

Any clues?
Thanks.

Luanne Coutinho

unread,
May 23, 2012, 12:04:52 AM5/23/12
to ne...@googlegroups.com
Did you try escaping with backticks ` ?

Razvan Tanase

unread,
May 25, 2012, 3:02:15 PM5/25/12
to Neo4j
Thanks. It worked fine with the backticks!

I didn't know about it.

On May 22, 9:04 pm, Luanne Coutinho <luanne.couti...@gmail.com> wrote:
> Did you try escaping with backticks ` ?
>

Razvan Tanase

unread,
May 29, 2012, 9:32:13 PM5/29/12
to Neo4j
Any ideas on how to write a lucene query where the key contains
special characters? How can we distinguish the colon in the key from
the colon that separates the index key from the value?
The backticks don't seem to work in this case...

Thanks,
Razvan

Luanne Coutinho

unread,
May 29, 2012, 11:11:22 PM5/29/12
to ne...@googlegroups.com
The lucene query you mention is used in the cypher start? Or is it a standalone query?
Did you try escaping with a backslash- that's usually used in lucene queries but I'm not sure whether it works on field names.

Michael Hunger

unread,
May 30, 2012, 2:16:06 AM5/30/12
to ne...@googlegroups.com
can you post your sample query?

Michael

Razvan Tanase

unread,
May 30, 2012, 1:34:41 PM5/30/12
to Neo4j
The nodes in my graph have properties named in namespace style,
something like Namespace:Parent.Property. All these properties are
indexed using the automatic node indexing feature of Neo4j. I want to
be able to issue a be able to issue a lucene query on the index in the
start clause of a cypher query, something like START n =
node:node_auto_index('key:value') RETURN n;

The problem here is that my key contains the colon special character,
how would I distinguish the colon from within the key name from the
one that separates the key from the value in the lucene query ?
For example, I want to be able to query a field name called
Neo:Graph.Writer for having the value "William Shakespeare". It should
have been something like:
START n = node:node_auto_index('Neo:Graph.Writer:\"William Shakespeare
\"') RETURN n;

The lucene documentation says the special characters are to be escaped
using the backslash (\), unfortunately escaping the colon from
Neo:Graph using the backslash throws an exception "Unfortunately, you
have run into a syntax error that we don't have a nice message for."

Thanks for the help.

On May 29, 11:16 pm, Michael Hunger <michael.hun...@neotechnology.com>
wrote:
> can you post your sample query?
>
> Michael
>
> Am 30.05.2012 um 03:32 schrieb Razvan Tanase:
>
>
>
>
>
>
>
> > Any ideas on how to write a lucene query where the key contains
> > special characters? How can we distinguish thecolonin the key from
> > thecolonthat separates the index key from the value?

Peter Neubauer

unread,
May 31, 2012, 2:19:55 PM5/31/12
to ne...@googlegroups.com
Razvan,
that looks like a bug to me. Could you please raise an issue on being
able to (double) escape characters in the index queries, so we can fix
it (or maybe you want to give it a shot?)

Cheers,

/peter neubauer

G:  neubauer.peter
S:  peter.neubauer
P:  +46 704 106975
L:   http://www.linkedin.com/in/neubauer
T:   @peterneubauer

If you can write, you can code - @coderdojomalmo
If you can sketch, you can use a graph database - @neo4j

Michael Hunger

unread,
May 31, 2012, 5:00:48 PM5/31/12
to ne...@googlegroups.com
did you try to quote the key name as well with double quotes?

also what about the simpler lookup syntax (note the backticks around the keyname)

>> START n = node:node_auto_index(`Neo:Graph.Writer`="William Shakespeare") RETURN n;

Razvan Tanase

unread,
Jun 1, 2012, 6:39:27 PM6/1/12
to Neo4j
Michael,

The simple lookup syntax works, but I don't want an exact match. I
want a free text search, and my understanding is that I have to use a
lucene query for that in order to work (correct me if I'm wrong).

Thanks for the suggestion though.



On May 31, 2:00 pm, Michael Hunger <michael.hun...@neotechnology.com>
wrote:
> did you try to quote the key name as well with double quotes?
>
> also what about the simpler lookup syntax (note the backticks around the keyname)
>
> >> START n = node:node_auto_index(`Neo:Graph.Writer`="William Shakespeare") RETURN n;
>
> Am 31.05.2012 um 20:19 schrieb Peter Neubauer:
>
>
>
>
>
>
>
> > Razvan,
> > that looks like a bug to me. Could you please raise an issue on being
> > able to (double) escape characters in the index queries, so we can fix
> > it (or maybe you want to give it a shot?)
>
> > Cheers,
>
> > /peter neubauer
>
> > G:  neubauer.peter
> > S:  peter.neubauer
> > P:  +46 704 106975
> > L:  http://www.linkedin.com/in/neubauer
> > T:   @peterneubauer
>
> > If you can write, you can code - @coderdojomalmo
> > If you can sketch, you can use a graph database - @neo4j
>
> > On Wed, May 30, 2012 at 7:34 PM, Razvan Tanase <razvan.geo...@gmail.com> wrote:
> >> The nodes in my graph have properties named in namespace style,
> >> something like Namespace:Parent.Property. All these properties are
> >> indexed using the automatic node indexing feature of Neo4j. I want to
> >> be able to issue a be able to issue a lucene query on the index in the
> >> start clause of a cypher query, something like START n =
> >> node:node_auto_index('key:value') RETURN n;
>
> >> The problem here is that my key contains thecolonspecial character,
> >> how would I distinguish thecolonfrom within the key name from the

Michael Hunger

unread,
Jun 2, 2012, 3:05:34 AM6/2/12
to ne...@googlegroups.com
Did you try to quote the key?

Michael

Michael Hunger

unread,
Jun 2, 2012, 3:06:16 AM6/2/12
to ne...@googlegroups.com
Otherwise feel free to raise an issue on github and tag it with "cypher" and "bug"

Cheers

Michael

Am 02.06.2012 um 00:39 schrieb Razvan Tanase:

Reply all
Reply to author
Forward
0 new messages