cancel
Showing results for 
Search instead for 
Did you mean: 

WebScript write and read gap

modestas
Champ in-the-making
Champ in-the-making
Hello,

I am experiencing quite annoying problem with writing and search for the object..

If you write something to alfresco on first request and try to read it (search for it) on another request.
You might not find it. You will experience something like a gap…

Writing example:

                NodeRef rootNode = nodeService.getRootNode(getStoreRef());
      NodeRef parentNode = documentSearchService.findNode(locationPath, rootNode);

      Map<QName, Serializable> properties = new HashMap<>();

      String documentName = newDocument.getName();
      properties.put(Model.PROP_NAME, documentName);


      return nodeService.createNode(parentNode, Model.ASSOC_CONTAINS, getQName(documentName), Model.TYPE_DOCUMENT, properties).getChildRef()


Searching example:

                SearchParameters sp = new SearchParameters();
      sp.addStore(getStoreRef());
      sp.setLanguage(SearchService.LANGUAGE_LUCENE);
      sp.setQuery(query);
      ResultSet results = null;
      try
      {
         results = searchService.query(sp);
         if (results != null)
         {
            return results.getNodeRefs();
         }
      }
      finally
      {
         if (logger.isDebugEnabled())
         {
            logger.debug("Executed query :" + query);
         }
         if (results != null)
         {
            results.close();
         }
      }


<strong>So my question is how to solve gap problem of writing and searching for that object?</strong>

respectfully,
Modestas
6 REPLIES 6

mitpatoliya
Star Collaborator
Star Collaborator
I do not see your query so do not know weather its proper or not(IN read block)

Are these both request part of same webscript?
If you have two seperate call then you should not face any issue in searching unless you are trying for free text search as it takes some time to index everything.

Issue only happens if you both operations are part of same transaction.

modestas
Champ in-the-making
Champ in-the-making
No. I do two separate calls to server. My query example is:


TYPE:"{http://www.nomagic.com/collaborator/model/1.0}View" AND @nm\:viewID:TREE_VIEW_ID0NodeView___18_0_2_8e10289_1415117719001_986707_4106 AND PATH:"/app:company_home/nm:Untitled1380984618752155//*"

mrogers
Star Contributor
Star Contributor
In general there will be a delay while the search subsystem indexes.   

However you should be able to avoid needing to search for content you have created.  In the example you have given above you already know the node ref of the newly created node. 

modestas
Champ in-the-making
Champ in-the-making
On first request to server i create new node ref.
On second request to server i try to find node ref which was created on first request and alfresco cant find it. But if i do delay for example 30s i will find that nodeRef…
So i kinda have a gap problem and don't know how to solve it.

mrogers
Star Contributor
Star Contributor
Why do you have to find a node ref of a node that you already know the node ref of ?

Or if you really must find it then use an API other than search that is not affected by the indexing delay.

modestas
Champ in-the-making
Champ in-the-making
ok sorry,
I forgot to tell something..

I do search because i am searching in content of nodeRef. And the id is not the db id. It is my json id which is stored in db.