1

I tring working with jcr jackrabbit oak, mongoDb and query.

The first I added a few file to repository.

Now I would like use full-text search.

When I use query :

    Session session = getSessions();

    Workspace workspace = session.getWorkspace();
    QueryManager queryManager = workspace.getQueryManager();

    Query query = queryManager.createQuery("SELECT [nt:file].* FROM [nt:file],Query.JCR_SQL2);

    QueryResult result = query.execute();

    log.info("Size nodes " + result.getRows().getSize());

From log : 2019-02-28 15:11:50.959 INFO 63248 --- [nio-8080-exec-5] c.e.r.service.DocumentManagementService : Size nodes 8

And so when i try use query like below :

Query query = queryManager.createQuery("SELECT [nt:file].* FROM [nt:file] WHERE contains(*, 'insert)",Query.JCR_SQL2);

c.e.r.service.DocumentManagementService : Size nodes 0

I;m sure each file has a word "insert".

What I doing wrong ?

Thanks a lot

So I also created index lucene :

String indexPath = "/oak:index/lucene";
Node lucene = JcrUtils.getOrCreateByPath(indexPath, JcrConstants.NT_UNSTRUCTURED,
        "oak:QueryIndexDefinition", session, false);
lucene.setProperty("async", "async");
lucene.setProperty(IndexConstants.TYPE_PROPERTY_NAME, "lucene");
lucene.setProperty(FulltextIndexConstants.EVALUATE_PATH_RESTRICTION, true);
lucene.setProperty(LuceneIndexConstants.INDEX_PATH, indexPath);
lucene.setProperty(FulltextIndexConstants.COMPAT_MODE, IndexFormatVersion.V2.getVersion());

Node indexRules = lucene.addNode(FulltextIndexConstants.INDEX_RULES, JcrConstants.NT_UNSTRUCTURED);
Node ntBaseRule = indexRules.addNode(JcrConstants.NT_BASE);

ntBaseRule.setProperty(FulltextIndexConstants.INCLUDE_PROPERTY_TYPES,
        new String[] {PropertyType.TYPENAME_BINARY, PropertyType.TYPENAME_STRING});

Node propNode = ntBaseRule.addNode(FulltextIndexConstants.PROP_NODE);

Node allPropNode = propNode.addNode("allProps");
allPropNode.setProperty(FulltextIndexConstants.PROP_ANALYZED, true);
allPropNode.setProperty(FulltextIndexConstants.PROP_NODE_SCOPE_INDEX, true);
allPropNode.setProperty(FulltextIndexConstants.PROP_NAME, FulltextIndexConstants.REGEX_ALL_PROPS);
allPropNode.setProperty(FulltextIndexConstants.PROP_IS_REGEX, true);
allPropNode.setProperty(FulltextIndexConstants.PROP_USE_IN_SPELLCHECK, true);

Node aggNode = lucene.addNode(FulltextIndexConstants.AGGREGATES);

Node aggFile = aggNode.addNode(JcrConstants.NT_FILE);
aggFile.addNode("include0").setProperty(FulltextIndexConstants.AGG_PATH, JcrConstants.JCR_CONTENT);

And size of nodes is 0.

Guys help me please :)

Basiaa
  • 41
  • 3

0 Answers0