1 Reply Latest reply on Aug 23, 2017 10:31 AM by rabo

    Index per workspace not working correctly




      I'm using ModeShape 5.4.1 with the local index provider and I'm using this query:


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

      Query query = queryManager.createQuery("SELECT * FROM [" + type.toString() + "] WHERE [jcr:name] = $name", Query.JCR_SQL2);

      query.bindValue("name", session.getValueFactory().createValue(nodeName));


      When running this without indexing enabled, I get exactly only the matching node(s) of the current workspace (expected behavior).

      However, when I enable the index then all matching nodes from all workspaces in the repository are returned.


      I set indexes dynamically from code like such:


      IndexDefinitionTemplate nodeByTypeIndexDefinitionTemplate = indexManager.createIndexDefinitionTemplate();

      nodeByTypeIndexDefinitionTemplate.setName("nodeByType_" + session.getWorkspace().getName());








      indexManager.registerIndex(nodeByTypeIndexDefinitionTemplate, false);


      And when I enabled debug logging I could see the following:


      2017-08-08 09:32:51,009 DEBUG [localhost-startStop-1] org.modeshape.jcr.index.local.LocalIndexProvider - Index provider 'local' is creating index in workspace 'admin': nodeByType_admin@local nodeType=nt:base column=jcr:primaryType(STRING) kind=NODE_TYPE sync=true workspaces=*


      Obviously, even though I set the index to only match one workspace, the rule is set to * so that it matches all workspaces.



      1. Even though an index is used for several workspaces a query should only return results from the current workspace

      2. Setting the indexes via code should respect the workspace matching rule


      Is this expected or are these bugs? If these are bugs is there any workaround?