The call to remove probably removes the node from the index, nit the key from the node. You need to remove then completely reminded the node, including the other two keys. ________________________________________ From: user-boun...@lists.neo4j.org [user-boun...@lists.neo4j.org] On Behalf Of ptashcka [ptash...@gmail.com] Sent: Tuesday, November 08, 2011 7:31 AM To: user@lists.neo4j.org Subject: [Neo4j] Numeric index update
Hi. I have a problem with following test (perform it on an empty database). First we add same node to the index with different keys and values. One of them is numeric. After that - check that node may be found using these keys and values. Then - update value for one of the keys and try to get node from indexes. For text index node is not null, but for numeric index node is not found, though the query is the same. public class DBTest { public static final String TEXT = "text"; public static final String NUMERIC = "numeric"; public static final String TEXT_1 = "text_1"; @Autowired GraphDatabaseService db; @Test public void updateIndex() throws Exception { Transaction tx = db.beginTx(); try { Node n = db.createNode(); getIndex().add(n, NUMERIC, new ValueContext(5).indexNumeric()); getIndex().add(n, TEXT, "text"); getIndex().add(n, TEXT_1, "text"); tx.success(); } catch (Exception e) { tx.failure(); } finally { tx.finish(); } Node n = getIndex().query(QueryContext.numericRange(NUMERIC, 5, 5, true, true)).getSingle(); assertTrue(n != null); n = getIndex().get(TEXT_1, "text").getSingle(); assertNotNull(n); tx = db.beginTx(); try { // Following line may be commented, it's addition of node that causes the problem getIndex().remove(n, TEXT, "text"); getIndex().add(n, TEXT, "text 1"); tx.success(); } catch (Exception e) { tx.failure(); } finally { tx.finish(); } n = getIndex().get(TEXT_1, "text").getSingle(); assertNotNull(n); n = getIndex().query(QueryContext.numericRange(NUMERIC, 5, 5, true, true)).getSingle(); // Test fails here assertNotNull(n); } private Index<Node> getIndex() { return db.index().forNodes("index"); } } -- View this message in context: http://neo4j-community-discussions.438527.n3.nabble.com/Numeric-index-update-tp3490124p3490124.html Sent from the Neo4j Community Discussions mailing list archive at Nabble.com. _______________________________________________ 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