Return-Path: X-Original-To: apmail-lucene-commits-archive@www.apache.org Delivered-To: apmail-lucene-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9810010EC3 for ; Thu, 8 Jan 2015 23:50:14 +0000 (UTC) Received: (qmail 56337 invoked by uid 500); 8 Jan 2015 23:50:15 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 56327 invoked by uid 99); 8 Jan 2015 23:50:15 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 08 Jan 2015 23:50:15 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id A842FAC0143; Thu, 8 Jan 2015 23:50:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1650423 - in /lucene/dev/branches/branch_5x: ./ solr/ solr/CHANGES.txt solr/solrj/ solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java Date: Thu, 08 Jan 2015 23:50:14 -0000 To: commits@lucene.apache.org From: markrmiller@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150108235014.A842FAC0143@hades.apache.org> Author: markrmiller Date: Thu Jan 8 23:50:14 2015 New Revision: 1650423 URL: http://svn.apache.org/r1650423 Log: SOLR-6839: Direct routing with CloudSolrServer will ignore the Overwrite document option. Modified: lucene/dev/branches/branch_5x/ (props changed) lucene/dev/branches/branch_5x/solr/ (props changed) lucene/dev/branches/branch_5x/solr/CHANGES.txt (contents, props changed) lucene/dev/branches/branch_5x/solr/solrj/ (props changed) lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java Modified: lucene/dev/branches/branch_5x/solr/CHANGES.txt URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/CHANGES.txt?rev=1650423&r1=1650422&r2=1650423&view=diff ============================================================================== --- lucene/dev/branches/branch_5x/solr/CHANGES.txt (original) +++ lucene/dev/branches/branch_5x/solr/CHANGES.txt Thu Jan 8 23:50:14 2015 @@ -367,6 +367,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/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java?rev=1650423&r1=1650422&r2=1650423&view=diff ============================================================================== --- lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java (original) +++ lucene/dev/branches/branch_5x/solr/solrj/src/java/org/apache/solr/client/solrj/request/UpdateRequest.java Thu Jan 8 23:50:14 2015 @@ -208,7 +208,16 @@ public class UpdateRequest extends Abstr routes.put(leaderUrl, request); } UpdateRequest urequest = (UpdateRequest) request.getRequest(); - urequest.add(doc); + Map 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/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java?rev=1650423&r1=1650422&r2=1650423&view=diff ============================================================================== --- lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java (original) +++ lucene/dev/branches/branch_5x/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java Thu Jan 8 23:50:14 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 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 {