Hey!

This is something that has been planned since the very first iteration of
Cypher, but no-one seemed to need it, so I have pushed it in front of me.

Now we seem to have an user that wants it, so I'll add it.

Don't hold your breath though - it'll be ready when it's ready.

Andrés

On Thu, Sep 29, 2011 at 1:10 PM, st.pa <st...@web.de> wrote:

> hi.
> when i use a cypher query to get the queued nodes associated via
> queue-relationships to a repository-node which has several million other
> relationships then it takes about six minutes to fill that result list:
>
> <pre>
> List<Node> list = new ArrayList<Node>();
> StringBuffer s = new StringBuffer();
> s.append("START repository = (");
> s.append((Long) controller.getRepositoryNode().getId());
> s.append(") MATCH (repository)-[:");
> s.append(Rels.REL_REPOSITORY_QUEUE);
> s.append("]->(node) RETURN node ORDER BY node.");
> s.append(Keys.KEY_TIMESTAMP);
> s.append(" SKIP ");
> s.append(Integer.toString(offset));
> s.append(" LIMIT ");
> s.append(Integer.toString(buffersize));
> Log.log(s.toString());
> Query query = this.parser.parse(s.toString());
> ExecutionResult result = this.engine.execute(query);
> Iterator<Node> iterator = result.columnAs("node");
> while (iterator.hasNext()) {
>   list.add(iterator.next());
> }
> </pre>
>
> but when i directly query the relationshipIndex containing all
> queue-relationships and assuming that sorting by timestamp is equivalent
> to sorting by node-ids then it completes in just half a minute, which is
> a dozen times faster:
>
> <pre>
> List<Node> list = new ArrayList<Node>();
> IndexHits<Relationship> hits =
> controller.getRelationIndexRepositoryUrlQueue().query(
>   Keys.KEY_TYPE,Rels.REL_REPOSITORY_QUEUE,
>   controller.getRepositoryNode(),null
> );
> List<Long> ids = new ArrayList<Long>();
> try {
>   for (Relationship hit : hits) {
>     ids.add(
>       hit.getEndNode().getId()
>     );
>   }
> } finally {
>   hits.close();
> }
> Collections.sort(ids);
> for (int i = offset; i < Math.min(offset + buffersize,ids.size()); i++) {
>   list.add(
>     this.graph.getNodeById(
>       ids.get(i)
>     )
>   );
> }
> </pre>
>
> now my question. how can i efficiently get such a result list sorted for
> some node property other than id. and question number two: how would a
> cypher statement look like if it supported relationship-indices. maybe
>
> <pre>
> START x = (1)
> MATCH (x)-[r:(MyRelationIndex,type,MyRelationType)]->(y)
> RETURN r,y
> ORDER BY y.somePropertyOtherThanId
> </pre>
>
> similar to nodeIndexLookups, where i give the name of the relationship
> index to use, key and value for the relationship, start and end nodes
> are given by (x) and (y) in this case. i'd like that feature very much
> and if i knew how i'd probably even help to get on with it but anyway i
> can be patient.
>
>
> kindly, st.p.
> _______________________________________________
> Neo4j mailing list
> User@lists.neo4j.org
> https://lists.neo4j.org/mailman/listinfo/user
>
_______________________________________________
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to