Full-text search in Neo4j with spaces

When neo4j lucene's auto index is in exact mode (which is the standard) queries like:

start n=node:node_auto_index('name:asfd\\ a*') return n

      

Work right (assuming you have a named node asdf adsf

).

However, if you switch the index to full text mode after these instructions (including deleting the index and reassigning the indexed property), the same query does not return any results.

Original question

Trying to search neo4j using full text index while setting wildcard after space doesn't work.

See the graphical list: http://gist.neo4j.org/?74c5a0bb4587cf4b5489

+3


source to share


3 answers


Insert Lucene part of Cypher with another pair of () brackets.

Lucene's query syntax documentation states that:

Lucene supports single and multi-character group searches within the same term (not in phrase queries).



Therefore, you cannot use a wildcard *

with a phrase (it won't work :) "asfd a*"

. Instead, find two separate members with an operator AND

:

start n=node:node_auto_index('name:(asfd AND a*)') return n

+3


source


To use a whitespace in an indexed query in a stale index, use two backslashes, since everyone gets eaten up by the cypher:

 start n=node:node_auto_index('name:asfd\\ a*') return n

      



If Cypher is used with Java, you need four backslashes because of quoting the java.

+3


source


You can write your request like:

MATCH (n)
WHERE n.name =~ 'asfd.*'
RETURN n

      

More information here: http://docs.neo4j.org/chunked/milestone/query-where.html

0


source







All Articles