You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2015/02/26 14:52:14 UTC
svn commit: r1662448 - in /lucene/dev/branches/lucene_solr_4_10: ./ solr/
solr/solrj/ solr/solrj/src/java/org/apache/solr/client/solrj/request/
solr/solrj/src/test/org/apache/solr/client/solrj/impl/
Author: shalin
Date: Thu Feb 26 13:52:13 2015
New Revision: 1662448
URL: http://svn.apache.org/r1662448
Log:
SOLR-6839: Direct routing with CloudSolrServer will ignore the Overwrite document option.
Modified:
lucene/dev/branches/lucene_solr_4_10/ (props changed)
lucene/dev/branches/lucene_solr_4_10/solr/ (props changed)
lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/lucene_solr_4_10/solr/solrj/ (props changed)
lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java
Modified: lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt?rev=1662448&r1=1662447&r2=1662448&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/CHANGES.txt Thu Feb 26 13:52:13 2015
@@ -62,6 +62,9 @@ Bug Fixes
* SOLR-6850: AutoAddReplicas makes a call to wait to see live replicas that times
out after 30 milliseconds instead of 30 seconds. (Varun Thacker via Mark Miller)
+* SOLR-6839: Direct routing with CloudSolrServer will ignore the Overwrite document option.
+ (Mark Miller)
+
================== 4.10.3 ==================
Bug Fixes
Modified: lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java?rev=1662448&r1=1662447&r2=1662448&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java Thu Feb 26 13:52:13 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/branches/lucene_solr_4_10/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java?rev=1662448&r1=1662447&r2=1662448&view=diff
==============================================================================
--- lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java (original)
+++ lucene/dev/branches/lucene_solr_4_10/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrServerTest.java Thu Feb 26 13:52:13 2015
@@ -32,6 +32,7 @@ import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
import org.apache.lucene.util.LuceneTestCase.Slow;
+import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
@@ -291,6 +292,48 @@ public class CloudSolrServerTest extends
del("*:*");
commit();
+
+ String collectionName = "overwriteCollection";
+ createCollection(collectionName, 1, 1, 1);
+ waitForRecoveriesToFinish(collectionName, false);
+ CloudSolrServer cloudClient = createCloudClient(collectionName);
+ try {
+ doc1 = new SolrInputDocument();
+ doc1.addField(id, "0");
+ doc1.addField("a_t", "hello1");
+ doc2 = new SolrInputDocument();
+ doc2.addField(id, "0");
+ doc2.addField("a_t", "hello2");
+
+ request = new UpdateRequest();
+ request.add(doc1);
+ request.add(doc2);
+ request.setAction(AbstractUpdateRequest.ACTION.COMMIT, false, false);
+ 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 Long getNumRequests(HttpSolrServer solrServer) throws