03-17-2017 10:25 AM
Hi All,
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
03-23-2017 03:31 PM
If you are using Alfresco 5.0 or above, there is no more Lucene. If you mean you are using the "search query language" Lucene, then you should stop doing that - it is a legacy language. Use Alfresco FTS or CMIS queries instead. These query languages are also capable of using a direct DB query if the query is simple enough (look for transactional metadata query in the documentation). In that case there is no delay for indexing at all. If your query is too complex to execute against the DB, you will always have to deal with the asynchronous indexing that SOLR performs.
Since I don't really know what other conditions you want to query for ("just created" is a bit too vague) it is difficult to suggest an alternative to looking up nodes via the NodeService. If you don't care about the type and/or other metadata on the document(s), and really want to look up "any" document "just created", you can do a simple CMIS query like:
SELECT * from cmis:document D where D.cmis:creationDate > TIMESTAMP '2017-03-23T19:30:00.000Z'
The above query selects all documents that have been created after the specified timestamp. Obviously you would have to dynamically create the query to adjust the timestamp to the meaning of "just created" you need to handle.
Explore our Alfresco products with the links below. Use labels to filter content by product module.