@Test void explicitIndexPopulationWithBunchOfFields() { assertTimeout( ofMillis( TEST_TIMEOUT ), () -> { BatchInserter batchNode = BatchInserters.inserter( directory.databaseDir() ); LuceneBatchInserterIndexProvider provider = new LuceneBatchInserterIndexProvider( batchNode ); try { BatchInserterIndex batchIndex = provider.nodeIndex( "node_auto_index", stringMap( IndexManager.PROVIDER, "lucene", "type", "fulltext" ) ); Map<String,Object> properties = IntStream.range( 0, 2000 ) .mapToObj( i -> Pair.of( Integer.toString( i ), randomAlphabetic( 200 ) ) ) .collect( toMap( Pair::first, Pair::other ) ); long node = batchNode.createNode( properties, Label.label( "NODE" ) ); batchIndex.add( node, properties ); } finally { provider.shutdown(); batchNode.shutdown(); } } ); } }
public MapDbCachingIndexProvider(BatchInserter inserter) { this(new LuceneBatchInserterIndexProvider(inserter)); }
@Override public void shutdown() { luceneIndex.shutdown(); db.close(); }
@Override public BatchInserterIndex nodeIndex(String indexName, Map<String, String> config) { return new CachingBatchInserterIndex(db,indexName,luceneIndex.nodeIndex(indexName,config)); }
@Override public BatchInserterIndex relationshipIndex(String indexName, Map<String, String> config) { return new CachingBatchInserterIndex(db,indexName,luceneIndex.relationshipIndex(indexName, config)); }
protected BatchInserterIndexProvider createIndexProvider(boolean luceneOnlyIndex) { return luceneOnlyIndex ? new LuceneBatchInserterIndexProvider(db) : new MapDbCachingIndexProvider(db); }
public Neo4jBatchGraph(final String directory) { this.rawGraph = BatchInserters.inserter(directory); this.indexProvider = new LuceneBatchInserterIndexProvider(this.rawGraph); }
public Neo4j2BatchGraph(final String directory) { this.rawGraph = BatchInserters.inserter(directory); this.indexProvider = new LuceneBatchInserterIndexProvider(this.rawGraph); }
public Neo4jBatchGraph(final String directory, final Map<String, String> parameters) { if (null == parameters) this.rawGraph = BatchInserters.inserter(directory); else this.rawGraph = BatchInserters.inserter(directory, parameters); this.indexProvider = new LuceneBatchInserterIndexProvider(this.rawGraph); }
public Neo4j2BatchGraph(final String directory, final Map<String, String> parameters) { if (null == parameters) this.rawGraph = BatchInserters.inserter(directory); else this.rawGraph = BatchInserters.inserter(directory, parameters); this.indexProvider = new LuceneBatchInserterIndexProvider(this.rawGraph); }
@Inject public GraphBatchImpl(BatchInserter inserter, @IndicatesUniqueProperty String uniqueProperty, @IndicatesIndexedProperties Set<String> indexedProperties, @IndicatesExactIndexedProperties Set<String> exactIndexedProperties, ConcurrentMap<String, Long> idMap, RelationshipMap relationshioMap) { this.inserter = inserter; this.idMap = idMap; this.relationshipMap = relationshioMap; indexProvider = new LuceneBatchInserterIndexProvider(inserter); nodeIndex = indexProvider.nodeIndex("node_auto_index", INDEX_CONFIG); this.uniqueProperty = uniqueProperty; this.indexedProperties = newHashSet(indexedProperties); this.indexedProperties.add(uniqueProperty); this.indexedExactProperties = newHashSet(exactIndexedProperties); }
@Test public void testBatchIndexToAutoIndex() throws IOException { BatchInserter inserter = BatchInserters.inserter(new File(path)); BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProvider(inserter); BatchInserterIndex index = indexProvider.nodeIndex("node_auto_index", MapUtil.stringMap("type", "exact")); long node = inserter.createNode(MapUtil.map("foo", "bar")); index.add(node, MapUtil.map("foo", "bar")); index.flush(); assertThat("Batch indexed node can be retrieved", index.get("foo", "bar").next(), is(node)); indexProvider.shutdown(); inserter.shutdown(); graphDb = getGraphDb(); try (Transaction tx = graphDb.beginTx()) { assertThat("AutoIndex is not enabled after reopening the graph", graphDb.index() .getNodeAutoIndexer().isEnabled(), is(false)); assertThat("AutoIndexed properties are not maintained after closing the graph", graphDb .index().getNodeAutoIndexer().getAutoIndexedProperties(), is(empty())); assertThat("Batch index properties are in the index", graphDb.index().getNodeAutoIndexer() .getAutoIndex().query("foo", "bar").size(), is(1)); tx.success(); } }