use of org.neo4j.graphdb.schema.IndexSetting in project neo4j by neo4j.
the class FulltextProceduresTest method prefixedFulltextIndexSettingMustBeRecognizedTogetherWithNonPrefixed.
@Test
void prefixedFulltextIndexSettingMustBeRecognizedTogetherWithNonPrefixed() {
try (Transaction tx = db.beginTx()) {
String mixedPrefixConfig = ", {`fulltext.analyzer`: 'english', eventually_consistent: 'true'}";
tx.execute(format(NODE_CREATE, DEFAULT_NODE_IDX_NAME, asStrList(LABEL.name()), asStrList(PROP) + mixedPrefixConfig)).close();
tx.execute(format(RELATIONSHIP_CREATE, DEFAULT_REL_IDX_NAME, asStrList(REL.name()), asStrList(PROP) + mixedPrefixConfig)).close();
tx.commit();
}
awaitIndexesOnline();
try (Transaction tx = db.beginTx()) {
for (IndexDefinition index : tx.schema().getIndexes()) {
if (index.getIndexType() != IndexType.FULLTEXT) {
continue;
}
Map<IndexSetting, Object> indexConfiguration = index.getIndexConfiguration();
Object eventuallyConsistentObj = indexConfiguration.get(IndexSettingImpl.FULLTEXT_EVENTUALLY_CONSISTENT);
assertNotNull(eventuallyConsistentObj);
assertThat(eventuallyConsistentObj).isInstanceOf(Boolean.class);
assertTrue((Boolean) eventuallyConsistentObj);
Object analyzerObj = indexConfiguration.get(IndexSettingImpl.FULLTEXT_ANALYZER);
assertNotNull(analyzerObj);
assertThat(analyzerObj).isInstanceOf(String.class);
assertEquals("english", analyzerObj);
}
tx.commit();
}
}
use of org.neo4j.graphdb.schema.IndexSetting in project neo4j by neo4j.
the class FulltextProceduresTest method prefixedFulltextIndexSettingMustBeRecognized.
@Test
void prefixedFulltextIndexSettingMustBeRecognized() {
try (Transaction tx = db.beginTx()) {
tx.execute(format(NODE_CREATE, DEFAULT_NODE_IDX_NAME, asStrList(LABEL.name()), asStrList(PROP) + EVENTUALLY_CONSISTENT_PREFIXED)).close();
tx.execute(format(RELATIONSHIP_CREATE, DEFAULT_REL_IDX_NAME, asStrList(REL.name()), asStrList(PROP) + EVENTUALLY_CONSISTENT_PREFIXED)).close();
tx.commit();
}
awaitIndexesOnline();
try (Transaction tx = db.beginTx()) {
for (IndexDefinition index : tx.schema().getIndexes()) {
if (index.getIndexType() != IndexType.FULLTEXT) {
continue;
}
Map<IndexSetting, Object> indexConfiguration = index.getIndexConfiguration();
Object eventuallyConsistentObj = indexConfiguration.get(IndexSettingImpl.FULLTEXT_EVENTUALLY_CONSISTENT);
assertNotNull(eventuallyConsistentObj);
assertThat(eventuallyConsistentObj).isInstanceOf(Boolean.class);
assertTrue((Boolean) eventuallyConsistentObj);
}
tx.commit();
}
}
use of org.neo4j.graphdb.schema.IndexSetting in project neo4j by neo4j.
the class SchemaAcceptanceTest method mustBeAbleToGetFullTextIndexConfig.
@Test
void mustBeAbleToGetFullTextIndexConfig() {
try (Transaction tx = db.beginTx()) {
IndexDefinition index = tx.schema().indexFor(label).withName("my_index").on(propertyKey).withIndexType(IndexType.FULLTEXT).create();
Map<IndexSetting, Object> config = index.getIndexConfiguration();
assertNotNull(config);
assertTrue(config.containsKey(IndexSettingImpl.FULLTEXT_ANALYZER));
tx.commit();
}
try (Transaction tx = db.beginTx()) {
IndexDefinition index = getIndex(tx, "my_index");
Map<IndexSetting, Object> config = index.getIndexConfiguration();
assertNotNull(config);
assertTrue(config.containsKey(IndexSettingImpl.FULLTEXT_ANALYZER));
tx.commit();
}
}
use of org.neo4j.graphdb.schema.IndexSetting in project neo4j by neo4j.
the class SchemaAcceptanceTest method mustBeAbleToSetFullTextIndexConfig.
@Test
void mustBeAbleToSetFullTextIndexConfig() {
try (Transaction tx = db.beginTx()) {
IndexDefinition index = tx.schema().indexFor(label).withName("my_index").on(propertyKey).withIndexType(IndexType.FULLTEXT).withIndexConfiguration(Map.of(IndexSettingImpl.FULLTEXT_ANALYZER, "swedish", IndexSettingImpl.FULLTEXT_EVENTUALLY_CONSISTENT, true)).create();
Map<IndexSetting, Object> config = index.getIndexConfiguration();
assertEquals("swedish", config.get(IndexSettingImpl.FULLTEXT_ANALYZER));
assertEquals(true, config.get(IndexSettingImpl.FULLTEXT_EVENTUALLY_CONSISTENT));
tx.commit();
}
try (Transaction tx = db.beginTx()) {
IndexDefinition index = getIndex(tx, "my_index");
Map<IndexSetting, Object> config = index.getIndexConfiguration();
assertEquals("swedish", config.get(IndexSettingImpl.FULLTEXT_ANALYZER));
tx.commit();
}
}
use of org.neo4j.graphdb.schema.IndexSetting in project neo4j by neo4j.
the class SchemaAcceptanceTest method mustBeAbleToSetBtreeIndexConfig.
@Test
void mustBeAbleToSetBtreeIndexConfig() {
try (Transaction tx = db.beginTx()) {
IndexDefinition index = tx.schema().indexFor(label).withName("my_index").on(propertyKey).withIndexConfiguration(Map.of(IndexSettingImpl.SPATIAL_CARTESIAN_MAX, new double[] { 200.0, 200.0 }, IndexSettingImpl.SPATIAL_WGS84_MIN, new double[] { -90.0, -90.0 })).create();
Map<IndexSetting, Object> config = index.getIndexConfiguration();
assertArrayEquals(new double[] { 200.0, 200.0 }, (double[]) config.get(IndexSettingImpl.SPATIAL_CARTESIAN_MAX));
assertArrayEquals(new double[] { -90.0, -90.0 }, (double[]) config.get(IndexSettingImpl.SPATIAL_WGS84_MIN));
tx.commit();
}
try (Transaction tx = db.beginTx()) {
IndexDefinition index = getIndex(tx, "my_index");
Map<IndexSetting, Object> config = index.getIndexConfiguration();
assertArrayEquals(new double[] { 200.0, 200.0 }, (double[]) config.get(IndexSettingImpl.SPATIAL_CARTESIAN_MAX));
assertArrayEquals(new double[] { -90.0, -90.0 }, (double[]) config.get(IndexSettingImpl.SPATIAL_WGS84_MIN));
tx.commit();
}
}
Aggregations