Neo4j:Cypher中的全文索引和自动索引 [英] Neo4j: fulltext indices and auto indexing in Cypher

查看:580
本文介绍了Neo4j:Cypher中的全文索引和自动索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在Cypher中为全文索引和自动索引而苦苦挣扎.

I'm currently struggeling with fulltext indices and auto indexing in Cypher.

我正在使用Java嵌入式Neo4j v 1.8.2.

I'm using Java embedded, Neo4j v 1.8.2.

我的基本问题是:如何使用Cypher查询全文索引?

My basic question is: How can fulltext indices be queried with Cypher?

当我创建以下索引时:

Index<Node> fulltextIndex = index.forNodes( "fulltextIndex",
            MapUtil.stringMap( IndexManager.PROVIDER, "lucene",
            "type", "fulltext" ) );

以下Cypher语句不返回任何内容:

The following Cypher statement does not return anything:

START n=node:fulltextIndex(name='*er*') RETURN n;

以下一段Java代码虽然返回了所需的节点:

The following piece of java code returns the desired node though:

Node found = fulltextIndex.query("name", "*er*").getSingle();
id= found.getId();
String cypherQuery="START n=node("+id+") RETURN n";

那么实际区别在哪里?为什么Cypher语句不起作用?

So where's actually the difference? Why does the Cypher statement not work?

我还想知道是否可以将全文索引与自动索引相结合吗?以下内容(在 http://docs.neo4j.org/chunked/milestone上看到/auto-indexing.html )似乎不起作用:

Also I'd like to if there's any way to combine fulltext indexing with auto indexing? The following (as seen on http://docs.neo4j.org/chunked/milestone/auto-indexing.html) does not seem to work:

Index<Node> fulltextIndex = index.forNodes("node_auto_index", "fulltextIndex",
            MapUtil.stringMap( IndexManager.PROVIDER, "lucene",
            "type", "fulltext" ) );

有什么想法吗?

谢谢!

推荐答案

尝试以下Cypher语句,因为您的Lucene查询似乎是错误的:

Try the following Cypher statement as your Lucene query seems to be wrong:

START n=node:fulltextIndex("name:*er*") RETURN n;

这篇关于Neo4j:Cypher中的全文索引和自动索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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