indexing - Filter index hits by node ids in Neo4j -
i have set of node id's (set< long >) , want restrict or filter results of query nodes in set. there performant way this?
set<node> query(final graphdatabaseservice graphdb, final set<long> nodeset) { final index<node> searchindex = graphdb.index().fornodes("search"); final indexhits<node> hits = searchindex.query(new querycontext("value*")); // return index hits in given set of node's? }
wouldn't faster other way round? if nodes set , compare property value looking for?
for (iterator it=nodeset.iterator();it.hasnext();) { node n=db.getnodebyid(it.next()); if (!n.getproperty("value","").equals("foo")) it.remove(); }
or suggestion
set<node> query(final graphdatabaseservice graphdb, final set<long> nodeset) { final index<node> searchindex = graphdb.index().fornodes("search"); final indexhits<node> hits = searchindex.query(new querycontext("value*")); set<node> result=new hashset<>(); (node n : hits) { if (nodeset.contains(n.getid())) result.add(n); } return result; }
Comments
Post a Comment