[Neo] Retrieving nodes ordered by property
tobias.ivarsson at neotechnology.com
Mon Jan 4 12:09:43 CET 2010
There are no plans to include any support for setting ordered properties or
any of the likes in core Neo4j.
Features like this would instead probably find its way
into auxiliary components (such as the index utilities), either an existing
component where it would fit, or in some new component.
As Mattias just said there is support for getting ordered results in the
lucene index service already. It doesn't look to me as if the sorting there
is very customizable, but I think the most commonly desired orderings are
On Mon, Jan 4, 2010 at 10:17 AM, Raul Raja Martinez <raulraja at gmail.com>wrote:
> Hi Tobias,
> Thanks for the info!
> I understand the implications of returning ordered nodes.
> Do you guys plan to build such support natively to neo4j even if it is
> for a basic set of node properties?
> While retrieving results ordered by property values or more extensive
> queries capabilities is provably not easy when dealing with a graph,
> it is currently one of
> the main things a programmer encounters when comparing neo4j to
> relational databases for storage and info retrieval.
> Would it make sense to have something like
> node.setOrderedProperty(property, value); so that the linked list
> based on the natural order of the value is kept internally by neo4j
> and then have another param in the traversers to specify that the
> traversal should follow the relationships established by the ordered
> linked nodes?
> If you guys think ordering based on property is out of the scope
> that's fine, I'm just asking in case we can avoid having to roll our
> own hack or component to get it working since ordered entities is a
> requirement in all of our current projects where we plan to use neo4j
> 2010/1/4 Tobias Ivarsson <tobias.ivarsson at neotechnology.com>:
> > Getting ordered results from any system always requires sorting, unless
> > ordering property is stored. And sorting always requires (at least) O(n)
> > memory and O( log(n!) ) time for comparison sort, possibly O( n ) time
> > sorting integer keys.
> > So if you want results to be sorted on an arbitrary property you will
> > to sort the entire result set and keep it around during your pagination
> > process (possibly redoing the query + entire sorting + skipping a few
> > to preserve memory).
> > If you know which properties you will want to order your results by when
> > are designing your database you can store the ordering information in the
> > database. I would suggest a linked list of relationships in between the
> > nodes, in the natural order for the sorting property.
> > You need to be aware of two things with this approach though.
> > The first one is that if the sorting property is unrelated to the
> > property, if you want something like "give me all nodes where x=15
> > by y", you will either have to store separate linked lists for each value
> > x, filter the result set while traversing through the results as they are
> > ordered by y, or revert to the sorting approach.
> > The second thing to be aware of is that insertion (and changing the value
> > the ordering property in some node) will require some overhead, to
> > the order.
> > If your queries are as simple as "give me all nodes where x>LOWER_LIMIT
> > x<UPPER_LIMIT ordered by x", and you can reduce the x property to a long
> > integer value, then the timeline index will do this for you. Otherwise
> > is no ready made component for this today.
> > Happy hacking,
> > Tobias
> > On Mon, Jan 4, 2010 at 1:30 AM, Raul Raja Martinez <raulraja at gmail.com
> >> Hi,
> >> Anybody has any experience returning indexed nodes ordered by a given
> >> property?.
> >> For example return all nodes ordered by creationDate. I understand that
> >> the node property is not indexed I'd have to iterate over all nodes
> >> then order then limit the results which seems overkill to me.
> >> I'd like to be able to do... "get me all nodes from start to limit
> >> by property".
> >> This is necessary when the data is iterated over using pagination and
> >> order determines what the next start node is next.
> >> _______________________________________________
> >> Neo mailing list
> >> User at lists.neo4j.org
> >> https://lists.neo4j.org/mailman/listinfo/user
> > --
> > Tobias Ivarsson <tobias.ivarsson at neotechnology.com>
> > Hacker, Neo Technology
> > www.neotechnology.com
> > Cellphone: +46 706 534857
> > _______________________________________________
> > Neo mailing list
> > User at lists.neo4j.org
> > https://lists.neo4j.org/mailman/listinfo/user
> Raul Raja
> Neo mailing list
> User at lists.neo4j.org
Tobias Ivarsson <tobias.ivarsson at neotechnology.com>
Hacker, Neo Technology
Cellphone: +46 706 534857
More information about the User