1

如果我在事务密码索引中不返回任何内容,但如果我在运行密码查询之前使用 SpringRest 或提交,它将返回节点。这是上下文:我有一个带有索引的对象,并且我正在通过 插入它Neo4jTemplate.save(),如果我用来GraphRepository.findByPropertyValue()保存对象,它会返回ok,但如果我使用Cypherwith index 它不会返回任何内容Cypher如果我通过 nodeID 获取它,则唯一返回该对象。

@NodeEntity
public class Group {
    @GraphId
    private Long nodeId;
    @Indexed(indexName = "groupIndex")
    private Long id;
}

使用时确定:

GraphRepository.findByProperty("id", 1L);
Neo4jTemplate.query("START n=node(1) RETURN n");

使用时什么都没有:

Map<String, Object> params = new HashMap<>();
params.put("id", 1L);
Neo4jTemplate.query("START n=node:groupIndex(id={id}) RETURN n", params);
4

1 回答 1

2

问题在于,在您的查询中,您要求以字符串格式提供索引,但在您的第一个示例中,您将它们指定为数字。

如果我没有记错的话,你就不能对数字存储的索引执行 Cypher 查询。你可以参考这个链接

@Indexed这里的简单解决方案是通过更改您的身份将该 ID 字段存储为非数字@Indexed(indexName = "groupIndex", numeric = false)

于 2013-06-19T16:32:18.287 回答