【问题标题】:Neo4j: fulltext indices and auto indexing in CypherNeo4j:Cypher 中的全文索引和自动索引
【发布时间】:2013-04-15 23:00:20
【问题描述】:

我目前正在努力使用 Cypher 中的全文索引和自动索引。

我使用的是 Java 嵌入式 Neo4j v 1.8.2。

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

当我创建以下索引时:

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

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

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

下面的 java 代码返回了所需的节点:

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

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

我还想知道是否有任何方法可以将全文索引与自动索引结合起来?以下(如http://docs.neo4j.org/chunked/milestone/auto-indexing.html 所示)似乎不起作用:

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

有什么想法吗?

谢谢!

【问题讨论】:

    标签: java neo4j cypher


    【解决方案1】:

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

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

    【讨论】:

    • 引号是否围绕整个属性-值对?通常它们只包裹在房产周围,对吧?无论如何,我尝试了以下方法(在嵌入的 java 中): String query="START n=node:fulltextIndex (\“name=*er*\“) RETURN n"; String query="START n=node:fulltextIndex ('name=*er*') RETURN n";两者都导致 NullPointerException
    • 哦,这很简单!非常感谢!!
    • 大约是时候接受我认为的答案了。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-13
    • 2011-10-13
    • 1970-01-01
    • 1970-01-01
    • 2012-05-12
    • 2013-01-13
    相关资源
    最近更新 更多