Revision: 17165
          http://sourceforge.net/p/gate/code/17165
Author:   valyt
Date:     2013-12-09 16:34:32 +0000 (Mon, 09 Dec 2013)
Log Message:
-----------
Added a non-documented method to the XML search API that collects the full 
document set before responding. This can be used to time the execution of 
queries in a remote M?\195?\173mir server.

Keeping it non-documented as we don;t want to encourage users to use it, 
because:
- time outs can occur during its execution
- it keeps a web thread occupied for the entire duration of the execution, 
which is wasteful.

Good this this commit message is entirely confidential and it does not get 
reported on a public mailing list, nor does it get associated with a commit 
into a publically accessible repository ;). 

Modified Paths:
--------------
    
mimir/trunk/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy

Modified: 
mimir/trunk/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
===================================================================
--- 
mimir/trunk/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
 2013-12-09 16:02:51 UTC (rev 17164)
+++ 
mimir/trunk/mimir-web/grails-app/controllers/gate/mimir/web/SearchController.groovy
 2013-12-09 16:34:32 UTC (rev 17165)
@@ -213,6 +213,38 @@
   }
   
   /**
+   * Gets the number of result documents.
+   * @return <code>-1</code> if the search has not yet completed, the total
+   * number of result document otherwise.
+   */
+  def documentsCountSync = {
+    def p = params["request"] ?: params
+    //a closure representing the return message
+    def message;
+    //get the query ID
+    String queryId = p["queryId"]
+    QueryRunner runner = searchService.getQueryRunner(queryId);
+    if(runner){
+      try{
+        //we have all required parameters
+        long docCount = runner.getDocumentsCountSync()
+        message = buildMessage(SUCCESS, null){
+          value(docCount)
+        }
+      }catch(Exception e){
+        message = buildMessage(ERROR,
+                "Error while obtaining the documents count: \"" +
+                e.getMessage() + "\"!", null)
+      }
+    } else{
+      message = buildMessage(ERROR, "Query ID ${queryId} not known!", null)
+    }
+    //return the results
+    render(contentType:"text/xml", builder: new StreamingMarkupBuilder(),
+        message)
+  }
+  
+  /**
    * Gets the number of result documents found so far. After the search 
    * completes, the result returned by this call is identical to that of 
    * {@link #documentsCount}.

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to