Search code examples
alfrescocmisalfresco-enterprise

Search for the node just created Alfresco JAVA


In one requirement I need to query just created document. If I use lucene search then it will take few seconds to do the indexing and may not come in the search result.

The query should be executing from some alfresco webscript or a scheduler which runs every 5 seconds.

Right now I am doing it by using NodeService and finding child by name which is not the efficient way to do. I am using JAVA API.

Is there any other way to do it?

Thank you


Solution

  • You don't mention what version of Alfresco you are using, but it looks like you are using Solr.

    If you just created the document, the recommendation is to keep the reference to it, so you don't have to search for it again.

    However, sometimes it is not possible to have the document reference. For example, client1 is not aware that client2 just created a document. If you are using Alfresco version 4.2 or later, you can probably enable Transactional Metadata Queries (TMQ), which allows you to perform searches against the database, so there is no Solr latency. Please review the whole section, because you need to comply with four conditions to use TMQ:

    1. Enable the TMQ patch, so the nodes properties tables get indexed in the database.
    2. Enable searches using the database, whenever possible (TRANSACTION_IF_POSSIBLE).
    3. Make sure that you use the correct query language (CMIS, AFTS, db-lucene, etc.)
    4. Your query must be supported by TMQ.