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 2013/01/14 18:59:33 UTC
svn commit: r1433013 - in /lucene/dev/trunk/solr: ./
core/src/java/org/apache/solr/update/processor/
core/src/test-files/solr/collection1/conf/
core/src/test/org/apache/solr/update/processor/
Author: shalin
Date: Mon Jan 14 17:59:32 2013
New Revision: 1433013
URL: http://svn.apache.org/viewvc?rev=1433013&view=rev
Log:
SOLR-4016: Deduplication does not work with atomic/partial updates so disallow atomic update requests which change signature generating fields.
Added:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java (with props)
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java
lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml
lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1433013&r1=1433012&r2=1433013&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Mon Jan 14 17:59:32 2013
@@ -602,6 +602,10 @@ Other Changes
* SOLR-4287: Removed "apache-" prefix from Solr distribution and artifact
filenames. (Ryan Ernst, Robert Muir, Steve Rowe)
+* SOLR-4016: Deduplication does not work with atomic/partial updates so
+ disallow atomic update requests which change signature generating fields.
+ (Joel Nothman, yonik, shalin)
+
================== 4.0.0 ==================
Versions of Major Components
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java?rev=1433013&r1=1433012&r2=1433013&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/update/processor/SignatureUpdateProcessorFactory.java Mon Jan 14 17:59:32 2013
@@ -134,7 +134,13 @@ public class SignatureUpdateProcessorFac
if (enabled) {
SolrInputDocument doc = cmd.getSolrInputDocument();
List<String> currDocSigFields = null;
+ boolean isPartialUpdate = DistributedUpdateProcessor.isAtomicUpdate(cmd);
if (sigFields == null || sigFields.size() == 0) {
+ if (isPartialUpdate) {
+ throw new SolrException
+ (ErrorCode.SERVER_ERROR,
+ "Can't use SignatureUpdateProcessor with partial updates on signature fields");
+ }
Collection<String> docFields = doc.getFieldNames();
currDocSigFields = new ArrayList<String>(docFields.size());
currDocSigFields.addAll(docFields);
@@ -149,6 +155,12 @@ public class SignatureUpdateProcessorFac
for (String field : currDocSigFields) {
SolrInputField f = doc.getField(field);
if (f != null) {
+ if (isPartialUpdate) {
+ throw new SolrException
+ (ErrorCode.SERVER_ERROR,
+ "Can't use SignatureUpdateProcessor with partial update request " +
+ "containing signature field: " + field);
+ }
sig.add(field);
Object o = f.getValue();
if (o instanceof Collection) {
Modified: lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml?rev=1433013&r1=1433012&r2=1433013&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml (original)
+++ lucene/dev/trunk/solr/core/src/test-files/solr/collection1/conf/solrconfig-tlog.xml Mon Jan 14 17:59:32 2013
@@ -47,6 +47,29 @@
</updateLog>
</updateHandler>
+ <updateRequestProcessorChain name="dedupe">
+ <processor class="org.apache.solr.update.processor.SignatureUpdateProcessorFactory">
+ <bool name="enabled">true</bool>
+ <bool name="overwriteDupes">true</bool>
+ <str name="fields">v_t,t_field</str>
+ <str name="signatureClass">org.apache.solr.update.processor.TextProfileSignature</str>
+ </processor>
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+ <updateRequestProcessorChain name="stored_sig">
+ <!-- this chain is valid even though the signature field is not
+ indexed, because we are not asking for dups to be overwritten
+ -->
+ <processor class="org.apache.solr.update.processor.SignatureUpdateProcessorFactory">
+ <bool name="enabled">true</bool>
+ <str name="signatureField">non_indexed_signature_sS</str>
+ <bool name="overwriteDupes">false</bool>
+ <str name="fields">v_t,t_field</str>
+ <str name="signatureClass">org.apache.solr.update.processor.TextProfileSignature</str>
+ </processor>
+ <processor class="solr.RunUpdateProcessorFactory" />
+ </updateRequestProcessorChain>
+
<requestHandler name="/admin/" class="org.apache.solr.handler.admin.AdminHandlers" />
</config>
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java?rev=1433013&r1=1433012&r2=1433013&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/SignatureUpdateProcessorFactoryTest.java Mon Jan 14 17:59:32 2013
@@ -64,7 +64,7 @@ public class SignatureUpdateProcessorFac
chain = "dedupe"; // set the default that most tests expect
}
- void checkNumDocs(int n) {
+ static void checkNumDocs(int n) {
SolrQueryRequest req = req();
try {
assertEquals(n, req.getSearcher().getIndexReader().numDocs());
@@ -353,7 +353,11 @@ public class SignatureUpdateProcessorFac
}
}
- private void addDoc(String doc) throws Exception {
+ private void addDoc(String doc) throws Exception {
+ addDoc(doc, chain);
+ }
+
+ static void addDoc(String doc, String chain) throws Exception {
Map<String, String[]> params = new HashMap<String, String[]>();
MultiMapSolrParams mmparams = new MultiMapSolrParams(params);
params.put(UpdateParams.UPDATE_CHAIN, new String[] { chain });
Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java?rev=1433013&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java (added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/update/processor/TestPartialUpdateDeduplication.java Mon Jan 14 17:59:32 2013
@@ -0,0 +1,74 @@
+package org.apache.solr.update.processor;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import com.google.common.collect.Maps;
+import org.apache.noggit.ObjectBuilder;
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.client.solrj.request.UpdateRequest;
+import org.apache.solr.common.SolrInputDocument;
+import org.apache.solr.core.SolrCore;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.List;
+import java.util.Map;
+
+import static org.apache.solr.update.processor.SignatureUpdateProcessorFactoryTest.addDoc;
+
+public class TestPartialUpdateDeduplication extends SolrTestCaseJ4 {
+ @BeforeClass
+ public static void beforeClass() throws Exception {
+ initCore("solrconfig-tlog.xml", "schema15.xml");
+ }
+
+ @Test
+ public void testPartialUpdates() throws Exception {
+ SignatureUpdateProcessorFactoryTest.checkNumDocs(0);
+ String chain = "dedupe";
+ // partial update
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField("id", "2a");
+ Map<String, Object> map = Maps.newHashMap();
+ map.put("set", "Hello Dude man!");
+ doc.addField("v_t", map);
+ UpdateRequest req = new UpdateRequest();
+ req.add(doc);
+ boolean exception_ok = false;
+ try {
+ addDoc(req.getXML(), chain);
+ } catch (Exception e) {
+ exception_ok = true;
+ }
+ assertTrue("Should have gotten an exception with partial update on signature generating field",
+ exception_ok);
+
+ SignatureUpdateProcessorFactoryTest.checkNumDocs(0);
+ addDoc(adoc("id", "2a", "v_t", "Hello Dude man!", "name", "ali babi'"), chain);
+ doc = new SolrInputDocument();
+ doc.addField("id", "2a");
+ map = Maps.newHashMap();
+ map.put("set", "name changed");
+ doc.addField("name", map);
+ req = new UpdateRequest();
+ req.add(doc);
+ addDoc(req.getXML(), chain);
+ addDoc(commit(), chain);
+ SignatureUpdateProcessorFactoryTest.checkNumDocs(1);
+ }
+}