Neo4j Cypher: Handling whitespace and wildcards in a Lucene fulltext search

喜夏-厌秋 提交于 2019-12-24 02:42:46

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!