use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class LuceneIndexRecoveryIT method createIndex.
private IndexDefinition createIndex(Label label) {
try (Transaction tx = db.beginTx()) {
IndexDefinition definition = db.schema().indexFor(label).on(NUM_BANANAS_KEY).create();
tx.success();
return definition;
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class LuceneIndexRecoveryIT method changeShouldBeIdempotentWhenDoingRecovery.
@Test
public void changeShouldBeIdempotentWhenDoingRecovery() throws Exception {
// Given
startDb(createLuceneIndexFactory());
IndexDefinition indexDefinition = createIndex(myLabel);
waitForIndex(indexDefinition);
long node = createNode(myLabel, 12);
rotateLogsAndCheckPoint();
updateNode(node, 13);
// And Given
killDb();
// When
startDb(createLuceneIndexFactory());
// Then
assertEquals(0, doIndexLookup(myLabel, 12).size());
assertEquals(1, doIndexLookup(myLabel, 13).size());
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class LuceneIndexRecoveryIT method shouldNotUpdateTwiceDuringRecovery.
@Test
public void shouldNotUpdateTwiceDuringRecovery() throws Exception {
// Given
startDb(createLuceneIndexFactory());
IndexDefinition indexDefinition = createIndex(myLabel);
waitForIndex(indexDefinition);
long nodeId = createNode(myLabel, 12);
updateNode(nodeId, 14);
// And Given
killDb();
// When
startDb(createLuceneIndexFactory());
// Then
assertEquals(0, doIndexLookup(myLabel, 12).size());
assertEquals(1, doIndexLookup(myLabel, 14).size());
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class IndexValuesValidationTest method validateNodePropertiesOnPopulation.
@Test
public void validateNodePropertiesOnPopulation() {
Label label = Label.label("populationTestNodeLabel");
String propertyName = "populationTestPropertyName";
try (Transaction transaction = database.beginTx()) {
Node node = database.createNode(label);
node.setProperty(propertyName, StringUtils.repeat("a", IndexWriter.MAX_TERM_LENGTH + 1));
transaction.success();
}
IndexDefinition indexDefinition = createIndex(label, propertyName);
try {
try (Transaction ignored = database.beginTx()) {
database.schema().awaitIndexesOnline(5, TimeUnit.MINUTES);
}
} catch (IllegalStateException e) {
try (Transaction ignored = database.beginTx()) {
String indexFailure = database.schema().getIndexFailure(indexDefinition);
assertThat("", indexFailure, Matchers.startsWith("java.lang.IllegalArgumentException: " + "Property value bytes length: 32767 is longer then 32766, " + "which is maximum supported length of indexed property value."));
}
}
}
use of org.neo4j.graphdb.schema.IndexDefinition in project neo4j by neo4j.
the class DatabaseContentVerifier method verifyIndex.
public void verifyIndex() {
try (Transaction tx = database.beginTx()) {
List<IndexDefinition> indexDefinitions = Iterables.asList(database.schema().getIndexes());
assertEquals(1, indexDefinitions.size());
IndexDefinition indexDefinition = indexDefinitions.get(0);
assertEquals("Label", indexDefinition.getLabel().name());
List<String> propKeys = Iterables.asList(indexDefinition.getPropertyKeys());
assertEquals(1, propKeys.size());
String propKey = propKeys.get(0);
assertEquals("prop", propKey);
tx.success();
}
}
Aggregations