Getting ordered results from any system always requires sorting, unless the
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 for
sorting integer keys.

So if you want results to be sorted on an arbitrary property you will have
to sort the entire result set and keep it around during your pagination
process (possibly redoing the query + entire sorting + skipping a few pages,
to preserve memory).

If you know which properties you will want to order your results by when you
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 filtering
property, if you want something like "give me all nodes where x=15 ordered
by y", you will either have to store separate linked lists for each value of
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 of
the ordering property in some node) will require some overhead, to preserve
the order.

If your queries are as simple as "give me all nodes where x>LOWER_LIMIT and
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 there
is no ready made component for this today.

Happy hacking,
Tobias

On Mon, Jan 4, 2010 at 1:30 AM, Raul Raja Martinez <raulr...@gmail.com>wrote:

> Hi,
>
> Anybody has any experience returning indexed nodes ordered by a given
> property?.
> For example return all nodes ordered by creationDate. I understand that if
> the node property is not indexed I'd have to iterate over all nodes first
> 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 ordered
> by property".
> This is necessary when the data is iterated over using pagination and the
> order determines what the next start node is next.
> _______________________________________________
> Neo mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>



-- 
Tobias Ivarsson <tobias.ivars...@neotechnology.com>
Hacker, Neo Technology
www.neotechnology.com
Cellphone: +46 706 534857
_______________________________________________
Neo mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to