如何从neo4j返回所有最新节点? [英] How to return all newest nodes from neo4j?

查看:484
本文介绍了如何从neo4j返回所有最新节点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以向neo4j查询最新节点?在这种情况下,索引属性"timestamp"以毫秒为单位记录每个节点上的时间.

Is it possible to query neo4j for the newest nodes? In this case, the indexed property "timestamp" records time in milliseconds on every node.

我发现的所有密码示例都涉及图类型查询-从节点n开始并遵循关系.返回在一个字段上排序的结果集的最佳方法是什么?在图数据库(如node4j?

All of the cypher examples I have lfound concern graph-type queries- "start at node n and follow relationships. What is the general best approach for returning resultsets sorted on one field? Is this even possible in a graph database such as node4j?

推荐答案

在嵌入式Java API中,可以使用Lucene构造添加排序.

In the embedded Java API it is possible to add sorting using Lucene constructs.

http://docs.neo4j.org/chunked /milestone/indexing-lucene-extras.html#indexing-lucene-query-objects http://blog.richeton.com/2009/05/12/lucene-sort-tips /

在服务器模式下,您可以将?order参数传递给lucene查找查询.

In the server mode you can pass an ?order parameter to the lucene lookup query.

http://docs.neo4j .org/chunked/milestone/rest-api-indexes.html#rest-api-find-node-by-query

取决于您对数据建立索引的方式(不是数字方式,因为lucene查询语法解析器和数字搜索:()存在问题,在cypher中,您可以这样做:

Depending on how you indexed your data (not numerically as there are issues with the lucene query syntax parser and numeric searches :( ), in cypher you can do:

start n=node:myindes('time: [1 to 1000]') return n order by n.time asc

还有更多图形方法可以做到这一点,例如通过以NEXT关系链接事件并返回此列表的head和next n个元素

There are also more graphy ways of doing that, e.g. by linking the events with a NEXT relationship and returning the head and next n elements from this list

http://docs.neo4j.org/chunked/milestone/cypher-cookbook-newsfeed .html

或创建时间树结构:

http://docs.neo4j.org/chunked/milestone/cypher-cookbook -path-tree.html

这篇关于如何从neo4j返回所有最新节点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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