Here's how we initialize non-lucene indexes in a spring environment;

public class RepositoryConfiguration implements DisposableBean {
[...]
public Repository getRepository() throws ContentException {
  NodeStore nodeStore = null;
  segmentStore = new FileStore(new File(oakRepositoryPath), 256);
  nodeStore = new SegmentNodeStore(segmentStore);

  oakRepository = new Jcr(nodeStore)
    .with(new LocalInitialContent())
    .withAsyncIndexing()
    .createRepository();
  return oakRepository;
}

public class LocalInitialContent implements RepositoryInitializer,
NodeTypeConstants {

  @SuppressWarnings("unused")
  private static NodeState createInitialContent() {
    NodeBuilder builder = EMPTY_NODE.builder();
    new InitialContent().initialize(builder);
    return ModifiedNodeState.squeeze(builder.getNodeState());
  }

  @Override
  public void initialize(NodeBuilder builder) {
    // optionally set up lucene full-text index

    createDefinition("jcr:name", index);

    createDefinition("ka:assetType", index);
    [.. lots of other property indexes ..]
  }

  private void createDefinition(String definition, NodeBuilder index) {
    IndexUtils.createIndexDefinition(index, definition, true, false,
      ImmutableSet.of(definition), null)
        .setProperty("reindex", true);
  }
}

In addition you would want a counter index, set up something like

    NodeBuilder entry = index.child("counter")
      .setProperty(JCR_PRIMARYTYPE, INDEX_DEFINITIONS_NODE_TYPE, NAME)
      .setProperty(TYPE_PROPERTY_NAME, "counter");

But I haven't been able to get oak to make use of it if configured
this way yet.

On 29 October 2015 at 12:48, Clay Ferguson <[email protected]> wrote:
> This file shows petty much everything I know... the sum total of my
> knowledge on indexes! :
> https://github.com/Clay-Ferguson/meta64/blob/master/src/main/java/com/meta64/mobile/repo/OakRepository.java
>
> I was only able to cobble that code together using very scant information
> from various sources, and I *think* it works. Unless I just broke it with
> my last commit!
>
> Best regards,
> Clay Ferguson
> [email protected]
>
>
> On Wed, Oct 28, 2015 at 9:20 PM, Peter Harrison <[email protected]>
> wrote:
>
>> I have moved from JackRabbit 2.X to JackRabbit Oak. I know that JackRabbit
>> Oak does not index as much as 2.X, and I am now getting the following
>> message in my query:
>>
>> Traversed 4000 nodes with filter ... consider creating an index or changing
>> the query.
>>
>> I have found the IndexUtils class, and some JavaDoc, but I can't see any
>> more detailed documentation on how it is used, or any examples.
>>
>> Where should I create the Index node in the tree? Does this control when a
>> property is indexed? Can you index only properties, or also node names? Are
>> node names already indexed?
>>
>> Thanks,
>> Peter
>>



-- 
-Tor

Reply via email to