You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mk...@apache.org on 2018/02/06 18:29:37 UTC
lucene-solr:branch_7x: SOLR-11459: Fix in-place nonexistent doc
update following existing doc update
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x 3251679ab -> 76d94c19b
SOLR-11459: Fix in-place nonexistent doc update following existing doc update
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/76d94c19
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/76d94c19
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/76d94c19
Branch: refs/heads/branch_7x
Commit: 76d94c19bb8f6480ec0119ad77d6601432b7099b
Parents: 3251679
Author: Mikhail Khludnev <mk...@apache.org>
Authored: Sun Feb 4 22:09:17 2018 +0300
Committer: Mikhail Khludnev <mk...@apache.org>
Committed: Tue Feb 6 21:09:57 2018 +0300
----------------------------------------------------------------------
solr/CHANGES.txt | 3 ++
.../apache/solr/update/AddUpdateCommand.java | 1 +
.../solr/update/TestInPlaceUpdatesDistrib.java | 40 ++++++++++++++++++++
3 files changed, 44 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/76d94c19/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 2b240a3..08a1836 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -166,6 +166,9 @@ Bug Fixes
* SOLR-11661: New HDFS collection reuses unremoved data from a deleted HDFS collection with same name causes
inconsistent view of documents (Cao Manh Dat, shalin)
+* SOLR-11459: In-place update of nonexistent doc following existing doc update fails to create the doc.
+ (Andrey Kudryavtsev via Mikhail Khludnev)
+
Optimizations
----------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/76d94c19/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
----------------------------------------------------------------------
diff --git a/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java b/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
index cb1af9a..3bfe934 100644
--- a/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
+++ b/solr/core/src/java/org/apache/solr/update/AddUpdateCommand.java
@@ -78,6 +78,7 @@ public class AddUpdateCommand extends UpdateCommand implements Iterable<Document
updateTerm = null;
isLastDocInBatch = false;
version = 0;
+ prevVersion = -1;
}
public SolrInputDocument getSolrInputDocument() {
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/76d94c19/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
index 14f0a7c..d01d68f 100644
--- a/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
+++ b/solr/core/src/test/org/apache/solr/update/TestInPlaceUpdatesDistrib.java
@@ -144,6 +144,7 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
outOfOrderUpdatesIndividualReplicaTest();
delayedReorderingFetchesMissingUpdateFromLeaderTest();
updatingDVsInAVeryOldSegment();
+ updateExistingThenNonExistentDoc();
// TODO Should we combine all/some of these into a single test, so as to cut down on execution time?
reorderedDBQIndividualReplicaTest();
@@ -411,6 +412,45 @@ public class TestInPlaceUpdatesDistrib extends AbstractFullDistribZkTestBase {
log.info("updatingDVsInAVeryOldSegment: This test passed fine...");
}
+
+ /**
+ * Test scenario:
+ * <ul>
+ * <li>Send a batch of documents to one node</li>
+ * <li>Batch consist of an update for document which is existed and an update for documents which is not existed </li>
+ * <li>Assumption which is made is that both updates will be applied: field for existed document will be updated,
+ * new document will be created for a non existed one</li>
+ * </ul>
+ *
+ */
+ private void updateExistingThenNonExistentDoc() throws Exception {
+ clearIndex();
+ index("id", 1, "inplace_updatable_float", "1", "title_s", "newtitle");
+ commit();
+ SolrInputDocument existingDocUpdate = new SolrInputDocument();
+ existingDocUpdate.setField("id", 1);
+ existingDocUpdate.setField("inplace_updatable_float", map("set", "50"));
+
+ SolrInputDocument nonexistentDocUpdate = new SolrInputDocument();
+ nonexistentDocUpdate.setField("id", 2);
+ nonexistentDocUpdate.setField("inplace_updatable_float", map("set", "50"));
+
+ SolrInputDocument docs[] = new SolrInputDocument[] {existingDocUpdate, nonexistentDocUpdate};
+
+ SolrClient solrClient = clients.get(random().nextInt(clients.size()));
+ add(solrClient, null, docs);
+ commit();
+ for (SolrClient client: new SolrClient[] {LEADER, NONLEADERS.get(0), NONLEADERS.get(1)}) {
+ for (SolrInputDocument expectDoc : docs) {
+ String docId = expectDoc.getFieldValue("id").toString();
+ SolrDocument actualDoc = client.getById(docId);
+ assertNotNull("expected to get doc by id:" + docId, actualDoc);
+ assertEquals("expected to update "+actualDoc,
+ 50.0f, actualDoc.get("inplace_updatable_float"));
+ }
+ }
+ }
+
/**
* Retries the specified 'req' against each SolrClient in "clients" untill the expected number of
* results are returned, at which point the results are verified using assertDocIdsAndValuesInResults