lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1650422 - in /lucene/dev/trunk/solr: CHANGES.txt solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
Date Thu, 08 Jan 2015 23:49:07 GMT
Author: markrmiller
Date: Thu Jan  8 23:49:07 2015
New Revision: 1650422

URL: http://svn.apache.org/r1650422
Log:
SOLR-6839: Direct routing with CloudSolrServer will ignore the Overwrite document option.

Modified:
    lucene/dev/trunk/solr/CHANGES.txt
    lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
    lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java

Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1650422&r1=1650421&r2=1650422&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Thu Jan  8 23:49:07 2015
@@ -409,6 +409,9 @@ Bug Fixes
 * SOLR-6643: Fix error reporting & logging of low level JVM Errors that occur when 
   loading/reloading a SolrCore (hossman)
 
+* SOLR-6839: Direct routing with CloudSolrServer will ignore the Overwrite document option.
+  (Mark Miller)
+
 Optimizations
 ----------------------
 

Modified: lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java?rev=1650422&r1=1650421&r2=1650422&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
(original)
+++ lucene/dev/trunk/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
Thu Jan  8 23:49:07 2015
@@ -208,7 +208,16 @@ public class UpdateRequest extends Abstr
           routes.put(leaderUrl, request);
         }
         UpdateRequest urequest = (UpdateRequest) request.getRequest();
-        urequest.add(doc);
+        Map<String,Object> value = entry.getValue();
+        Boolean ow = null;
+        if (value != null) {
+          ow = (Boolean) value.get(OVERWRITE);
+        }
+        if (ow != null) {
+          urequest.add(doc, ow);
+        } else {
+          urequest.add(doc);
+        }
       }
     }
     

Modified: lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java?rev=1650422&r1=1650421&r2=1650422&view=diff
==============================================================================
--- lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
(original)
+++ lucene/dev/trunk/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
Thu Jan  8 23:49:07 2015
@@ -20,6 +20,7 @@ package org.apache.solr.client.solrj.imp
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+
 import org.apache.http.client.HttpClient;
 import org.apache.lucene.util.LuceneTestCase.Slow;
 import org.apache.solr.client.solrj.SolrQuery;
@@ -123,6 +124,52 @@ public class CloudSolrClientTest extends
     allTests();
     stateVersionParamTest();
     customHttpClientTest();
+    testOverwriteOption();
+  }
+
+  private void testOverwriteOption() throws Exception, SolrServerException,
+      IOException {
+    String collectionName = "overwriteCollection";
+    createCollection(collectionName, controlClientCloud, 1, 1);
+    waitForRecoveriesToFinish(collectionName, false);
+    CloudSolrClient cloudClient = createCloudClient(collectionName);
+    try {
+      SolrInputDocument doc1 = new SolrInputDocument();
+      doc1.addField(id, "0");
+      doc1.addField("a_t", "hello1");
+      SolrInputDocument doc2 = new SolrInputDocument();
+      doc2.addField(id, "0");
+      doc2.addField("a_t", "hello2");
+      
+      UpdateRequest request = new UpdateRequest();
+      request.add(doc1);
+      request.add(doc2);
+      request.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);
+      NamedList<Object> response = cloudClient.request(request);
+      QueryResponse resp = cloudClient.query(new SolrQuery("*:*"));
+      
+      assertEquals("There should be one document because overwrite=true", 1, resp.getResults().getNumFound());
+      
+      doc1 = new SolrInputDocument();
+      doc1.addField(id, "1");
+      doc1.addField("a_t", "hello1");
+      doc2 = new SolrInputDocument();
+      doc2.addField(id, "1");
+      doc2.addField("a_t", "hello2");
+      
+      request = new UpdateRequest();
+      // overwrite=false
+      request.add(doc1, false);
+      request.add(doc2, false);
+      request.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);
+      response = cloudClient.request(request);
+      
+      resp = cloudClient.query(new SolrQuery("*:*"));
+
+      assertEquals("There should be 3 documents because there should be two id=1 docs due
to overwrite=false", 3, resp.getResults().getNumFound());
+    } finally {
+      cloudClient.shutdown();
+    }
   }
 
   private void allTests() throws Exception {



Mime
View raw message