Search for the node just created JAVA

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

Search for the node just created JAVA

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

1 Reply
afaust
Master

Re: Search for the node just created JAVA

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.