Hi,
I'm trying to define an index on a custom property to speedup my query, but
it looks like is not used.
The query I'm running extracts all the nodes having a certain value for a
custom property:

Query query = queryManager.createQuery("SELECT p.* FROM
[custom:starrable] AS p WHERE p.[custom:starProp] = 'marco'",
Query.JCR_SQL2);


I create the index defining my custom IndexInitializer like this:

public class RepositoryIndexInitializer extends InitialContent {

    public void initialize(NodeBuilder builder) {
        super.initialize(builder);
        NodeBuilder root = builder.getBaseState().builder();
        NodeBuilder index = IndexUtils.getOrCreateOakIndex(root);

        NodeBuilder nt = IndexUtils.createIndexDefinition(index,
"starredIndex", true, false, ImmutableList.of("custom:starProp"),
null);
        IndexUtils.createReferenceIndex(index);
    }

}

 And here is how i define my repository:

Jcr jcr = new Jcr(nodeStore).with(new InitialContent()).with(new
SecurityProviderImpl()).with(new RepositoryIndexInitializer());

Repository repository = jcr.createRepository();

But when i execute the query I always get the warning message:

WARN org.apache.jackrabbit.oak.spi.query.Cursors$TraversingCursor -
Traversed 1000 nodes with filter Filter(query=SELECT p.* FROM
[custom:starrable] AS p WHERE ISDESCENDANTNODE('/myfolder/') AND
p.[custom:starProp] = 'marco', path=/myfolder//*,
property=[custom:starProp=[marco]]); consider creating an index or changing
the query


What am I doing wrong?

Marco.

Reply via email to