Skip to content

Commit e2c97b6

Browse files
committed
fix issue with repeated call to apoc.index.addAllNodes
1 parent 4025fa6 commit e2c97b6

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/main/java/apoc/index/FreeTextSearch.java

+3
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,9 @@ private Index<Node> index(String index, Map<String, List<String>> structure) {
171171
log.info("Dropping existing index '%s', with config: %s", index, config);
172172
old.delete();
173173
}
174+
tx.success();
175+
}
176+
try (Transaction tx = db.beginTx()) {
174177
Map<String, String> config = new HashMap<>(CONFIG);
175178
config.put("labels", escape(structure.keySet()));
176179
for (Map.Entry<String, List<String>> entry : structure.entrySet()) {

src/test/java/apoc/index/FreeTextSearchTest.java

+11
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,17 @@ public void shouldCreateFreeTextIndexWithMultipleLabels() throws Exception {
9292
assertSingleNode("stuff", termQuery("London"), hasProperty("name", "London"), hasLabel("City"));
9393
}
9494

95+
@Test
96+
public void shouldHandleRepeatedCalls() throws Exception {
97+
// given
98+
execute("CREATE (:Person{name:'George Goldman', nick:'GeeGee'}), (:Person{name:'Cyrus Jones', age:103})");
99+
execute("CALL apoc.index.addAllNodes('people', {Person:['name','nick']})");
100+
execute("CALL apoc.index.addAllNodes('people', {Person:['name','nick']})");
101+
102+
// then
103+
assertSingle(search("people", "GeeGee"), hasProperty("name", "George Goldman"));
104+
assertSingle(search("people", "Jones"), hasProperty("name", "Cyrus Jones"));
105+
}
95106
@Test
96107
public void shouldQueryFreeTextIndex() throws Exception {
97108
// given

0 commit comments

Comments
 (0)