use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class CypherResultSubGraph method from.
public static SubGraph from(Result result, GraphDatabaseService gds, boolean addBetween) {
final CypherResultSubGraph graph = new CypherResultSubGraph();
final List<String> columns = result.columns();
for (Map<String, Object> row : loop(result)) {
for (String column : columns) {
final Object value = row.get(column);
graph.addToGraph(value);
}
}
for (IndexDefinition def : gds.schema().getIndexes()) {
if (graph.getLabels().contains(def.getLabel())) {
graph.addIndex(def);
}
}
for (ConstraintDefinition def : gds.schema().getConstraints()) {
if (graph.getLabels().contains(def.getLabel())) {
graph.addConstraint(def);
}
}
if (addBetween) {
graph.addRelationshipsBetweenNodes();
}
return graph;
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class SubGraphExporter method exportIndexes.
private Collection<String> exportIndexes() {
final List<String> result = new ArrayList<>();
for (IndexDefinition index : graph.getIndexes()) {
if (!index.isConstraintIndex()) {
Iterator<String> propertyKeys = index.getPropertyKeys().iterator();
if (!propertyKeys.hasNext()) {
throw new IllegalStateException("Indexes should have at least one property key");
}
String key = quote(propertyKeys.next());
if (propertyKeys.hasNext()) {
throw new RuntimeException("Exporting compound indexes is not implemented yet");
}
String label = quote(index.getLabel().name());
result.add("create index on :" + label + "(" + key + ")");
}
}
Collections.sort(result);
return result;
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexRecoveryIT method createIndexAndAwaitPopulation.
private void createIndexAndAwaitPopulation(Label label) {
IndexDefinition index = createIndex(label);
try (Transaction tx = db.beginTx()) {
db.schema().awaitIndexOnline(index, 10, SECONDS);
tx.success();
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexRestartIT method createIndex.
private IndexDefinition createIndex() {
try (Transaction tx = db.beginTx()) {
IndexDefinition index = db.schema().indexFor(myLabel).on("number_of_bananas_owned").create();
tx.success();
return index;
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexSamplingCancellationTest method indexOn.
private IndexDefinition indexOn(Label label, String propertyKey) {
IndexDefinition index;
try (Transaction tx = db.beginTx()) {
index = db.schema().indexFor(label).on(propertyKey).create();
tx.success();
}
return index;
}
Aggregations