Search in sources :

Example 1 with IndexSetting

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();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexSetting(org.neo4j.graphdb.schema.IndexSetting) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with IndexSetting

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();
    }
}
Also used : Transaction(org.neo4j.graphdb.Transaction) IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexSetting(org.neo4j.graphdb.schema.IndexSetting) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with IndexSetting

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();
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexSetting(org.neo4j.graphdb.schema.IndexSetting) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with IndexSetting

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();
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexSetting(org.neo4j.graphdb.schema.IndexSetting) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 5 with IndexSetting

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();
    }
}
Also used : IndexDefinition(org.neo4j.graphdb.schema.IndexDefinition) IndexSetting(org.neo4j.graphdb.schema.IndexSetting) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

Test (org.junit.jupiter.api.Test)7 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)7 IndexDefinition (org.neo4j.graphdb.schema.IndexDefinition)7 IndexSetting (org.neo4j.graphdb.schema.IndexSetting)7 RepeatedTest (org.junit.jupiter.api.RepeatedTest)5 Transaction (org.neo4j.graphdb.Transaction)2 ConstraintDefinition (org.neo4j.graphdb.schema.ConstraintDefinition)1