Esempio n. 1
0
  public IndexDefinition _createIndex(Label label, String key) {
    Schema schema = graphDb.schema();

    for (IndexDefinition index : schema.getIndexes(label))
      for (String property : index.getPropertyKeys())
        if (property.equals(key)) return index; // already existing

    return schema.indexFor(label).on(key).create();
  }
Esempio n. 2
0
 public Collection<String> exportIndexes() {
   Collection<String> result = new ArrayList<String>();
   for (IndexDefinition index : graph.indexes()) {
     StringBuilder keys = new StringBuilder();
     for (String key : index.getPropertyKeys()) {
       if (keys.length() > 0) keys.append(", ");
       keys.append(quote(key));
     }
     result.add("create index on :" + quote(index.getLabel().name()) + "(" + keys + ")");
   }
   return result;
 }