lucene-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [lucene-solr] thomaswoeckinger commented on a change in pull request #1030: SOLR-13961: Fix Atomic Update unset nested documents
Date Sat, 23 Nov 2019 10:33:28 GMT
thomaswoeckinger commented on a change in pull request #1030: SOLR-13961: Fix Atomic Update
unset nested documents
URL: https://github.com/apache/lucene-solr/pull/1030#discussion_r349867533
 
 

 ##########
 File path: solr/core/src/test/org/apache/solr/update/processor/NestedAtomicUpdateTest.java
 ##########
 @@ -642,6 +642,118 @@ public void testBlockAtomicRemove() throws Exception {
     );
   }
 
+  @Test
+  public void testBlockAtomicSetToNull() throws Exception {
+    SolrInputDocument doc = sdoc("id", "1",
+        "cat_ss", new String[] {"aaa", "ccc"},
+        "child1", sdocs(sdoc("id", "2", "cat_ss", "child"), sdoc("id", "3", "cat_ss", "child")));
+    assertU(adoc(doc));
+
+    BytesRef rootDocId = new BytesRef("1");
+    SolrCore core = h.getCore();
+    SolrInputDocument block = RealTimeGetComponent.getInputDocument(core, rootDocId,
+        RealTimeGetComponent.Resolution.ROOT_WITH_CHILDREN);
+    // assert block doc has child docs
+    assertTrue(block.containsKey("child1"));
+
+    assertJQ(req("q", "id:1"), "/response/numFound==0");
+
+    // commit the changes
+    assertU(commit());
+
+    SolrInputDocument committedBlock = RealTimeGetComponent.getInputDocument(core, rootDocId,
+        RealTimeGetComponent.Resolution.ROOT_WITH_CHILDREN);
+    BytesRef childDocId = new BytesRef("2");
+    // ensure the whole block is returned when resolveBlock is true and id of a child doc
is provided
+    assertEquals(committedBlock.toString(), RealTimeGetComponent
+        .getInputDocument(core, childDocId, RealTimeGetComponent.Resolution.ROOT_WITH_CHILDREN).toString());
+
+    assertJQ(req("q", "id:1"), "/response/numFound==1");
+
+    assertJQ(req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\""
+
+        ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}, {\"id\":\"3\",\"cat_ss\":[\"child\"]}]}}");
+
+    assertU(commit());
+
+    assertJQ(req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\""
+
+        ", cat_ss:[\"aaa\",\"ccc\"], child1:[{\"id\":\"2\",\"cat_ss\":[\"child\"]}, {\"id\":\"3\",\"cat_ss\":[\"child\"]}]}}");
+
+    doc = sdoc("id", "1", "child1", Collections.singletonMap("set", null));
+    addAndGetVersion(doc, params("wt", "json"));
+
+    assertJQ(req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={\"doc\":{'id':\"1\",
cat_ss:[\"aaa\",\"ccc\"]}}");
+
+    assertU(commit());
+
+    // a cut-n-paste of the first big query, but this time it will be retrieved from the
index rather than the
+    // transaction log
+    // this requires ChildDocTransformer to get the whole block, since the document is retrieved
using an index lookup
+    assertJQ(req("qt", "/get", "id", "1", "fl", "id, cat_ss, child1, [child]"), "=={'doc':{'id':'1',
cat_ss:[\"aaa\",\"ccc\"]}}");
+
+    // ensure the whole block has been committed correctly to the index.
+    assertJQ(req("q", "id:1", "fl", "*, [child]"),
+        "/response/numFound==1",
+        "/response/docs/[0]/id=='1'",
+        "/response/docs/[0]/cat_ss/[0]==\"aaa\"",
+        "/response/docs/[0]/cat_ss/[1]==\"ccc\"");
+  }
+
+  @Test
+  public void testBlockAtomicSetToEmpty() throws Exception {
 
 Review comment:
   You are right, was a long day, but yes changed it .....

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org


Mime
View raw message