ACS JAVA SearchService

cancel
Showing results for 
Search instead for 
Did you mean: 
franciscoduarte
Member II

ACS JAVA SearchService

Hello,

I'm developing a JAVA action which is being triggered by a rule.

Every document that enters this folder will be moved to a subfolder.

The criteria for the subfolder is the max num of documents inside it. We don't want to have more than 5 documents inside each subfolder. If all subfolders are full a new one is created.

The problem is that if a document is moved to one of the subfolders, making it full (with 5 documents inside) and after this we upload again a new document to the main folder that will trigger the action, it seems that my SearchService is not detecting that that subfolder already has 5 documents and will move it to there, making the folder with more documents than expected.

But if I wait some time (let's say one minute) it detects ok all the documents inside the subfolder. So, the problem doesn't seem to be in the query. It seems that the SearchService needs some time to "refresh" and get the correct results.

My query is as follows:

SearchParameters searchParametersDocs = new SearchParameters();
searchParameters.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
searchParameters.setLanguage(SearchService.LANGUAGE_FTS_ALFRESCO);
searchParameters.setMaxItems(1);
searchParameters.setQuery("TYPE:'cm:content' AND PARENT:'" + parentFolder + "'");
searchParameters.addFacetQuery("TYPE:'cm:content' AND PARENT:'" + parentFolder + "'");
Collection<Integer> total = serviceRegistry.getSearchService().query(searchParametersDocs).getFacetQueries().values();

 Can you advise on this?

Thanks