alexanoid
alexanoid

Reputation: 25862

Neo4j automatic index doesn't work first time

I have a following test:

  @Test
    public void testAutoIndexingAndFuzzySearch() {
        GraphDatabaseService graphDb = template.getGraphDatabaseService();

        Index<Node> autoIndex = graphDb.index().forNodes("node_auto_index");
        graphDb.index().setConfiguration(autoIndex, "type", "fulltext");
        graphDb.index().setConfiguration(autoIndex, "to_lower_case", "true");
        graphDb.index().setConfiguration(autoIndex, "analyzer", StandardAnalyzerV36.class.getName());

        sampleDataGenerator.generateSampleDataJava();

        List<Product> products = // query - "name:aDbma~";

        Assert.assertFalse(products.isEmpty());
    }

Every first time on the fresh embedded database the test fails. Auto index doesn't work. Test starts to work only each second time. First time products are empty..

What could be a reason of this behaviour ?

Upvotes: 0

Views: 47

Answers (1)

Michael Hunger
Michael Hunger

Reputation: 41706

Pass in the configuration to the very first call to forNodes(index,config)

Upvotes: 1

Related Questions