use of org.neo4j.index.lucene.unsafe.batchinsert.LuceneBatchInserterIndexProvider in project neo4j by neo4j.
the class LegacyIndexTest method legacyIndexPopulationWithBunchOfFields.
@Test(timeout = TEST_TIMEOUT)
public void legacyIndexPopulationWithBunchOfFields() throws Exception {
BatchInserter batchNode = BatchInserters.inserter(directory.graphDbDir());
LuceneBatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(batchNode);
try {
BatchInserterIndex batchIndex = provider.nodeIndex("node_auto_index", stringMap(IndexManager.PROVIDER, "lucene", "type", "fulltext"));
Map<String, Object> properties = new HashMap<>();
for (int i = 0; i < 2000; i++) {
properties.put(Integer.toString(i), RandomStringUtils.randomAlphabetic(200));
}
long node = batchNode.createNode(properties, Label.label("NODE"));
batchIndex.add(node, properties);
} finally {
provider.shutdown();
batchNode.shutdown();
}
}
use of org.neo4j.index.lucene.unsafe.batchinsert.LuceneBatchInserterIndexProvider in project neo4j by neo4j.
the class TestLuceneBatchInsert method cachesDoesntGetFilledWhenAddingForAnExistingIndex.
@Test
public void cachesDoesntGetFilledWhenAddingForAnExistingIndex() throws Exception {
// Prepare the test case, i.e. create a store with a populated index.
BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(inserter);
String indexName = "index";
BatchInserterIndex index = provider.nodeIndex(indexName, LuceneIndexImplementation.EXACT_CONFIG);
String key = "name";
index.add(0, map(key, "Mattias"));
provider.shutdown();
shutdownInserter();
// Test so that the next run doesn't start caching inserted stuff right away,
// because that would lead to invalid results being returned.
startInserter();
provider = new LuceneBatchInserterIndexProvider(inserter);
index = provider.nodeIndex(indexName, LuceneIndexImplementation.EXACT_CONFIG);
index.setCacheCapacity(key, 100000);
assertCacheIsEmpty(index, key);
index.add(1, map(key, "Persson"));
index.flush();
assertCacheIsEmpty(index, key);
assertEquals(1, index.get(key, "Persson").getSingle().intValue());
provider.shutdown();
}
use of org.neo4j.index.lucene.unsafe.batchinsert.LuceneBatchInserterIndexProvider in project neo4j by neo4j.
the class TestLuceneBatchInsert method cachesShouldBeFilledWhenAddToMultipleIndexesCreatedNow.
@Test
public void cachesShouldBeFilledWhenAddToMultipleIndexesCreatedNow() throws Exception {
BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider(inserter);
BatchInserterIndex index = provider.nodeIndex("index1", LuceneIndexImplementation.EXACT_CONFIG);
index.setCacheCapacity("name", 100000);
String nameKey = "name";
String titleKey = "title";
assertCacheIsEmpty(index, nameKey, titleKey);
index.add(0, map("name", "Neo", "title", "Matrix"));
assertCacheContainsSomething(index, nameKey);
assertCacheIsEmpty(index, titleKey);
BatchInserterIndex index2 = provider.nodeIndex("index2", LuceneIndexImplementation.EXACT_CONFIG);
index2.setCacheCapacity("title", 100000);
assertCacheIsEmpty(index2, nameKey, titleKey);
index2.add(0, map("name", "Neo", "title", "Matrix"));
assertCacheContainsSomething(index2, titleKey);
assertCacheIsEmpty(index2, nameKey);
provider.shutdown();
}
Aggregations