You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-commits@lucene.apache.org by bd...@apache.org on 2007/04/30 07:28:51 UTC

svn commit: r533591 - /lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java

Author: bdelacretaz
Date: Sun Apr 29 22:28:51 2007
New Revision: 533591

URL: http://svn.apache.org/viewvc?view=rev&rev=533591
Log:
Fix Solr result detection to adapt to slightly modified output format (though the result detection is still a hack)

Modified:
    lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java

Modified: lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java?view=diff&rev=533591&r1=533590&r2=533591
==============================================================================
--- lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java (original)
+++ lucene/solr/trunk/src/java/org/apache/solr/util/SimplePostTool.java Sun Apr 29 22:28:51 2007
@@ -44,7 +44,7 @@
   public static final String DEFAULT_POST_URL = "http://localhost:8983/solr/update";
   public static final String POST_ENCODING = "UTF-8";
   public static final String VERSION_OF_THIS_TOOL = "1.0";
-  private static final String SOLR_OK_RESPONSE = "<result status=\"0\"></result>";
+  private static final String SOLR_OK_RESPONSE_EXCERPT = "<int name=\"status\">0</int>";
   protected URL solrUrl;
 
   private class PostException extends RuntimeException {
@@ -79,7 +79,7 @@
         info("COMMITting Solr index changes..");
         final StringWriter sw = new StringWriter();
         t.commit(sw);
-        warnIfNotExpectedResponse(sw.toString(),SOLR_OK_RESPONSE);
+        warnIfNotExpectedResponse(sw.toString(),SOLR_OK_RESPONSE_EXCERPT);
       }
       info(posted + " files POSTed to " + solrUrl);
     } catch(IOException ioe) {
@@ -98,7 +98,7 @@
         info("POSTing file " + srcFile.getName());
         postFile(srcFile, sw);
         filesPosted++;
-        warnIfNotExpectedResponse(sw.toString(),SOLR_OK_RESPONSE);
+        warnIfNotExpectedResponse(sw.toString(),SOLR_OK_RESPONSE_EXCERPT);
       } else {
         warn("Cannot read input file: " + srcFile);
       }
@@ -110,8 +110,8 @@
    *  TODO: parse the response and check it XMLwise, here we just check it as an unparsed String  
    */
   static void warnIfNotExpectedResponse(String actual,String expected) {
-    if(!actual.equals(expected)) {
-      warn("Unexpected response from Solr: '" + actual + "', expected '" + expected + "'");
+    if(actual.indexOf(expected) < 0) {
+      warn("Unexpected response from Solr: '" + actual + "' does not contain '" + expected + "'");
     }
   }