2
votes

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
I found this post explaining the reason: groups.google.com/forum/#!msg/neo4j/tedDZkwwHXc/CX6x93B39A0J - Mik378
I found out in other SO question that whitespaced phrases need to be surrounded with backticks if followed by ~ operator and whole Lucene query surrounded with () brackets. Fuzzy query worked for me. In your wildcards case, try START w=node:myFullTextIndex('title:(*Hello World*)') - that worked in the handpicked tests in my database. Please let me know how it goes. - Daniel Krizian

1 Answers

2
votes

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)