问题
I created a FullText index named: myFullTextIndex
.
When I want to search for the pattern: Hello World
, the query looks like:
START w=node:myFullTextIndex('title:"Hello World"')
That works pretty well.
However, I don't manage to search for the same string surrounded by wildcards.
I expect a search on this pattern to return a result: *Hello World*
I tried:
START w=node:myFullTextIndex('title:"*Hello World*"')
and
START w=node:myFullTextIndex('title:*"Hello World"*')
but doesn't work (syntax errors occurred).
Any idea?
回答1:
When using complex operators and whitespaces, surround the embedded Lucene query with () brackets.
In your case with wildcards, the following Cypher works in the handpicked tests in my database.
START w=node:myFullTextIndex('title:(*Hello World*)')
where Lucene part is
*Hello World*
Note that () brackets embed the Lucene subpart safely within the Cypher syntax.
See also Neo4j: Lucene phrase matching using Cypher (fuzzy)
来源:https://stackoverflow.com/questions/21615300/neo4j-cypher-handling-whitespace-and-wildcards-in-a-lucene-fulltext-search