Github user dsmiley commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/455#discussion_r226709264
  
    --- Diff: 
solr/core/src/test/org/apache/solr/update/processor/AtomicUpdateBlockTest.java 
---
    @@ -59,39 +52,147 @@ public void before() {
     
       @Test
       public void testMergeChildDoc() throws Exception {
    -    SolrInputDocument doc = new SolrInputDocument();
    -    doc.setField("id", "1");
    -    doc.setField("cat_ss", new String[]{"aaa", "ccc"});
    -    doc.setField("child", Collections.singletonList(sdoc("id", "2", 
"cat_ss", "child")));
    +    SolrInputDocument newChildDoc = sdoc("id", "3", "cat_ss", "child");
    +    SolrInputDocument addedDoc = sdoc("id", "1",
    +        "cat_ss", Collections.singletonMap("add", "bbb"),
    +        "child", Collections.singletonMap("add", sdocs(newChildDoc)));
    +
    +    SolrInputDocument dummyBlock = sdoc("id", "1",
    +        "cat_ss", new ArrayList<>(Arrays.asList("aaa", "ccc")),
    +        "_root_", "1", "child", new ArrayList<>(sdocs(addedDoc)));
    +    dummyBlock.removeField(VERSION);
    +
    +    SolrInputDocument preMergeDoc = new SolrInputDocument(dummyBlock);
    +    AtomicUpdateDocumentMerger docMerger = new 
AtomicUpdateDocumentMerger(req());
    +    docMerger.merge(addedDoc, dummyBlock);
    +    assertEquals("merged document should have the same id", 
preMergeDoc.getFieldValue("id"), dummyBlock.getFieldValue("id"));
    +    assertDocContainsSubset(preMergeDoc, dummyBlock);
    +    assertDocContainsSubset(addedDoc, dummyBlock);
    +    assertDocContainsSubset(newChildDoc, (SolrInputDocument) ((List) 
dummyBlock.getFieldValues("child")).get(1));
    +    assertEquals(dummyBlock.getFieldValue("id"), 
dummyBlock.getFieldValue("id"));
    +  }
    +
    +  @Test
    +  public void testBlockAtomicQuantities() throws Exception {
    +    SolrInputDocument doc = sdoc("id", "1", "string_s", "root");
         addDoc(adoc(doc), "nested-rtg");
     
    -    BytesRef rootDocId = new BytesRef("1");
    -    SolrCore core = h.getCore();
    -    SolrInputDocument block = RealTimeGetComponent.getInputDocument(core, 
rootDocId, true);
    -    // assert block doc has child docs
    -    assertTrue(block.containsKey("child"));
    +    List<SolrInputDocument> docs = IntStream.range(10, 20).mapToObj(x -> 
sdoc("id", String.valueOf(x), "string_s", 
"child")).collect(Collectors.toList());
    +    doc = sdoc("id", "1", "children", Collections.singletonMap("add", 
docs));
    +    addAndGetVersion(doc, params("update.chain", "nested-rtg", "wt", 
"json"));
     
    -    assertJQ(req("q","id:1")
    -        ,"/response/numFound==0"
    +    assertU(commit());
    +
    +    assertJQ(req("q", "_root_:1"),
    +        "/response/numFound==11");
    +
    +    assertJQ(req("q", "string_s:child", "fl", "*", "rows", "1000000"),
    +        "/response/numFound==10");
    +
    +    // ensure updates work when block has more than 10 children
    --- End diff --
    
    Why is 10 special?


---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to