cancel
Showing results for 
Search instead for 
Did you mean: 

New node indexing

schipmolder
Champ on-the-rise
Champ on-the-rise
I've been running into this issue quite a few times and usually find a way around it but I would like to understand what i can do differently for the next time it becomes an issue so all suggestions are much appreciated.

Imagine 2 webscripts, one that creates a node of custom type X and another that lists  all nodes of that same custom type X.
Now when I call the first web script the node gets created and i can get it's nodeRef etc, but when I then call the second web script that same node isn't found. This lasts for about 10 to 15 seconds and then the node is listed.

I assume (but correct me if I'm wrong) that this is because of the indexing settings of, in this case, SOLR and that it takes 15 seconds for it to realise a node has been added and for it to be indexed, but is there a way to change this so the node is found immediately after it has been created?
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

you are correct, this is because of the inherent asynchronous indexing of SOLR. You can reduce the interval of SOLR checking, but you can't avoid this delay completely ever. If you require transaction level consistency for searches, you should try to adapt your web scripts for it, i.e. by using <a href="http://docs.alfresco.com/4.2/concepts/intrans-metadata.html">transactional metadata queries</a> or other DB-bound lookup.

At least, you should enable the additional DB indices by setting system.metadata-query-indexes.ignored=false in alfresco-global.properties and try to avoid complex queries requiring tokenisation / partial matches, ORing… You should also only use either CMIS or Alfresco FTS - these are the only search languages that currently support transactional metadata queries. The level of support differs a bit - the feature was originally targeting CMIS and thus support is a bit better here, but I found that special cases are actually better handled in FTS queries ("NOT ASPECT" queries for one seem to be impossible in CMIS, but work fine it FTS).

If you try to do XPath lookups, use the proper JavaScript API method for this. DO NOT use search.xpathSearch which executes an index-bound query with the XPath search language (not transactionally supported) - INSTEAD USE search.selectNodes which has always been DB-bound since introduction (even before transactional metadata queries).

Regards
Axel

schipmolder
Champ on-the-rise
Champ on-the-rise
Thanks a lot Axel, I have just included the system.metadata-query-indexes.ignored=false line and rewritten parts of the web script that lists the nodes to CMIS and that seems to have resolved the issue completely!

I do now notice something I could never notice before though, but I think that's transaction related and not relevant for this thread at all.

Thanks again!