使用空格在Neo4j中进行全文搜索 [英] Full text search in Neo4j with spaces

查看:122
本文介绍了使用空格在Neo4j中进行全文搜索的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当neo4j lucene自动索引处于精确模式(这是默认设置)的查询类型时:

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

正常工作(假设你有一个节点名为 asdf adsf 例如



然而,当将索引切换为fulltext 模式遵循这些说明(包括删除索引并重新分配索引属性),那么相同的查询不会返回任何结果。



原始问题



尝试通过全文索引搜索neo4j时,如果在空格不起作用之后放置通配符,那么可以使用通配符。

请参阅Graph Gist: http://gist.neo4j.org/?74c5a0bb4587cf4b5489

解决方案

使用另一对()括号将Cypher的Lucene部分嵌入。


$ b Lucene查询语法文档指出:


Lucene支持单(不在短语查询中)。


因此,您不能使用 * 带短语的通配符(这不起作用:asfd a *)。而是用 AND 运算符搜索两个单项:

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


When the neo4j lucene auto index is in exact mode (which is the default) queries of the type:

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

Work correctly (assuming you have a node with the name asdf adsf for instance.

However when switching the index to "fulltext" mode following these instructions (including deleting the index and reassigning the indexed property), then the same query doesn't return any results.

Original Question

Trying to search neo4j via the full text index when putting the wildcard character after a space doesn't work.

See the Graph Gist : http://gist.neo4j.org/?74c5a0bb4587cf4b5489

解决方案

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

Lucene query syntax documentation states that:

Lucene supports single and multiple character wildcard searches within single terms (not within phrase queries).

Therefore you can't use * wildcard with phrase (this will not work: "asfd a*"). Instead, search for two single terms with AND operator:

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

这篇关于使用空格在Neo4j中进行全文搜索的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆