1

尝试执行以下密码查询(从 neoclipse 执行 ok)

START a=node(*)   MATCH a-[:Knows]->p   WHERE (p.Firstname! = "Steve" )   RETURN p

来自neo4jclient,带有以下语句

protected void Populate()
    {
        var client = new GraphClient(new Uri("http://altdev:7474/db/data"));
        client.Connect();

        var query = client.Cypher
            .Start(new RawCypherStartBit("all", "node(*)"))
            .Match("all-[:Knows]->p")
            .Where((Person p) => p.Firstname == "Steve")
            .Return<Node<Person>>("Person");

        var people = query.Results;
 }

客户端抛出异常,如下

The query was: START all=node(*)
MATCH all-[:Knows]->p
WHERE (p.Firstname! = {p0})
RETURN Person

The response status was: 400 Bad Request

The response from Neo4j (which might include useful detail!) was: {
  "message" : "Unknown identifier `Person`.",
  "exception" : "SyntaxException",
  "fullname" : "org.neo4j.cypher.SyntaxException",
  "stacktrace" : [ "org.neo4j.cypher.internal.symbols.SymbolTable.evaluateType(SymbolTable.scala:59)", "org.neo4j.cypher.internal.commands.expressions.Identifier.evaluateType(Identifier.scala:47)", "org.neo4j.cypher.internal.commands.expressions.Expression.throwIfSymbolsMissing(Expression.scala:52)", "org.neo4j.cypher.internal.pipes.ColumnFilterPipe$$anonfun$throwIfSymbolsMissing$1.apply(ColumnFilterPipe.scala:61)", "org.neo4j.cypher.internal.pipes.ColumnFilterPipe$$anonfun$throwIfSymbolsMissing$1.apply(ColumnFilterPipe.scala:61)", "scala.collection.immutable.List.foreach(List.scala:309)", "org.neo4j.cypher.internal.pipes.ColumnFilterPipe.throwIfSymbolsMissing(ColumnFilterPipe.scala:61)", "org.neo4j.cypher.internal.pipes.PipeWithSource.<init>(Pipe.scala:63)", "org.neo4j.cypher.internal.pipes.ColumnFilterPipe.<init>(ColumnFilterPipe.scala:30)", "org.neo4j.cypher.internal.executionplan.builders.ColumnFilterBuilder.handleReturnClause(ColumnFilterBuilder.scala:60)", "org.neo4j.cypher.internal.executionplan.builders.ColumnFilterBuilder.apply(ColumnFilterBuilder.scala:38)", "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.prepareExecutionPlan(ExecutionPlanImpl.scala:54)", "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.<init>(ExecutionPlanImpl.scala:36)", "org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:80)", "org.neo4j.cypher.ExecutionEngine$$anonfun$prepare$1.apply(ExecutionEngine.scala:80)", "org.neo4j.cypher.internal.LRUCache.getOrElseUpdate(LRUCache.scala:37)", "org.neo4j.cypher.ExecutionEngine.prepare(ExecutionEngine.scala:80)", "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:72)", "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:76)", "org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)", "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:94)", "java.lang.reflect.Method.invoke(Method.java:616)", "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)" ]
}

如您所见,基本上查询是相同的。我试图获得的节点是_type“Person”

TIA

马塞洛

4

3 回答 3

1

在您的MATCH条款中,您使用身份p

.Match("all-[:Knows]->p")          // becomes MATCH all-[:Knows]->p

在您的RETURN条款中,您更改为使用身份Person

.Return<Node<Person>>("Person");   // becomes RETURN person

您需要选择一个并保持一致。

还集成了其他一些清理,您的完整查询应该是:

   var query = client.Cypher
        .Start(new { all = All.Nodes })
        .Match("all-[:Knows]->p")
        .Where((Person p) => p.Firstname == "Steve")
        .Return<Person>("p");
于 2013-08-05T20:29:51.953 回答
0

您正在尝试返回一个未分配给查询中任何内容的 Person 节点。

于 2013-08-05T19:08:51.043 回答
0

这取决于您创建 Cypher 代码的方式,特别是您返回的内容:

var query = client.Cypher
    .Start(new RawCypherStartBit("all", "node(*)"))
    .Match("all-[:Knows]->p")
    .Where((Person p) => p.Firstname == "Steve")
    .Return<Node<Person>>("p"); // <-- THIS LINE SHOULD SAY 'P' NOT 'Person'

return 语句要求名称与您定义的节点相同。所以你使用:all-[:knows]->p你定义的地方p。现在你需要退货。

(这就是彼得在他的回答中所说的:))

于 2013-08-05T20:31:45.983 回答