public CloseableIterable<T> get(final String key, final Object value) { if (Vertex.class.isAssignableFrom(this.indexClass)) return (CloseableIterable<T>) new Neo4j2BatchVertexIterable(this.graph, this.rawIndex.get(key, value)); else return (CloseableIterable<T>) new Neo4j2BatchEdgeIterable(this.graph, this.rawIndex.get(key, value)); }
public CloseableIterable<T> get(final String key, final Object value) { if (Vertex.class.isAssignableFrom(this.indexClass)) return (CloseableIterable<T>) new Neo4jBatchVertexIterable(this.graph, this.rawIndex.get(key, value)); else return (CloseableIterable<T>) new Neo4jBatchEdgeIterable(this.graph, this.rawIndex.get(key, value)); }
private long lookup(String index,String property,Object value) { Long id = indexFor(index).get(property, value).getSingle(); return id==null ? -1 : id; }
@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(); } }