cancel
Showing results for 
Search instead for 
Did you mean: 

Executing a search (SolR) on Alfresco startup

eroux
Champ in-the-making
Champ in-the-making
Hello,

I use Alfresco 5.0.0.3 (but the problem is the same on a version with SolR indexation) and I want to execute a lucene search on Alfresco startup but I have the following error "SOLR queries can not be executed while the repository is bootstrapping".

Is there a possibility to execute a search during Alfresco startup or just after the startup ?


Regards,
Emmanuel
5 REPLIES 5

afaust
Legendary Innovator
Legendary Innovator
Hello,

you can't execute full fledged searches during Startup and there is no way around it. But you can execute a restricted search based on the "transactional metadata query" feature available since Alfresco 4.2. In essence, you have to use fts-alfresco or cmis-alfresco (you should never ever use Lucene language anymore) and the query must not contain PATH, CONTAINS(), IN_TREE, OR, ISNULL and similarily complex fragments. You also have to enable the Feature by letting Alfresco create the neceesary database indices during Schema bootstrap.

See <a href="http://docs.alfresco.com/5.0/concepts/intrans-metadata.html">transactional metadata query documentation</a> for Details.

Regards
Axel

eroux
Champ in-the-making
Champ in-the-making
Thanks Axel.

I've enable the patch that adds the required indexes to the database (by adding the property system.metadata-query-indexes.ignored=false).
Then I've started Alfreco without making my search (the patch is executed).
Then I've restarted Alfresco with my search and I've the following error : The patch to add the indexes to support in-transactional metadata queries has not been applied

My code is :
final SearchParameters params = new SearchParameters();
params.addStore(StoreRef.STORE_REF_WORKSPACE_SPACESSTORE);
params.setLanguage(SearchService.LANGUAGE_CMIS_ALFRESCO);
params.setQuery("select * from ins:secureDocument where ins:chrono IS NOT NULL");
params.setQueryConsistency(QueryConsistency.TRANSACTIONAL);
final ResultSet resultSet = searchService.query(params);

Regards,
Emmanuel

eroux
Champ in-the-making
Champ in-the-making
Axel,

It's working.
My code wasn't executed at the right place on Alfresco startup (I've put my code in my module "executeInternal()" method).

Big thanks for your help.

Regards,
Emmanuel

FYI, Putting the code inside a bootstrap patch (org.alfresco.repo.admin.patch.Patch) does not work.

For some reason, OptionalPatchApplicationCheckBootstrapBean, which is responsible for determining if patch was applied, is never called, hene returning always false, which in turn causes the message "he patch to add the indexes to support in-transactional metadata queries has not been applied" to be thrown. (Seems like a buggy behaviour in my opinion...)

 

Using a module component as mentionned by Emmanuel (with the executeOnceOnly option set to true) made it work.

afaust
Legendary Innovator
Legendary Innovator

The OptionalPatchApplicationCheckBootstrapBean is called, but only very, very late in the startup process when most (if not all) of Alfresco has already been initialised. This means it will be called way after patches have been executed, which is why they cannot rely on this class. Even module components cannot rely on this bean to have already been called, as they will be called as part of the "onBootstrap" event handling, and the ordering between module components / the patch check bootstrap is not guaranteed / may be dependent on operating system / file system / Spring file processing order. In practice though, the default file order should be sufficient to make module components works as long as no one overrides core Spring beans.