mirror of https://github.com/apache/lucene.git
SOLR-11459: Fix in-place nonexistent doc update following existing doc update
This commit is contained in:
parent
812d400807
commit
c508068240
|
@ -186,6 +186,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
|
||||
----------------------
|
||||
|
||||
|
|
|
@ -78,6 +78,7 @@ public class AddUpdateCommand extends UpdateCommand implements Iterable<Document
|
|||
updateTerm = null;
|
||||
isLastDocInBatch = false;
|
||||
version = 0;
|
||||
prevVersion = -1;
|
||||
}
|
||||
|
||||
public SolrInputDocument getSolrInputDocument() {
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue