Solr doesn't overwrite - duplicated uniqueKey entries

◇◆丶佛笑我妖孽 提交于 2019-12-04 05:12:05

Thanks for your feedback! I write this as answer since it is too long otherwise. I actually got the same response from the mailing list:

Mikhail Khludnev Hello Sebastian,

Mixing standalone docs and blocks doesn't work. There are a plenty of issues open.

On Wed, Mar 9, 2016 at 3:02 PM, Sebastian Riemer wrote:

Hi,

to actually describe my problem in short, instead of just linking to the test applicaton, using SolrJ I do the following:

1) Create a new document as a parent and commit

    SolrInputDocument parentDoc = new SolrInputDocument();
    parentDoc.addField("id", "parent_1");
    parentDoc.addField("name_s", "Sarah Connor");
    parentDoc.addField("blockJoinId", "1");
    solrClient.add(parentDoc);
    solrClient.commit();

2) Create a new document with the same unique-id as in 1) with a child document appended

    SolrInputDocument parentDocUpdateing = new SolrInputDocument();
    parentDocUpdateing.addField("id", "parent_1");
    parentDocUpdateing.addField("name_s", "Sarah Connor");
    parentDocUpdateing.addField("blockJoinId", "1");

    SolrInputDocument childDoc = new SolrInputDocument();
    childDoc.addField("id", "child_1");
    childDoc.addField("name_s", "John Connor");
    childDoc.addField("blockJoinId", "1");

    parentDocUpdateing.addChildDocument(childDoc);
    solrClient.add(parentDocUpdateing);
    solrClient.commit();

3) Results in 2 Documents with id="parent_1" in solr index

Is this normal behaviour? I thought the existing document should be updated instead of generating a new document with same id.

For a full working test application please see orginal message.

Best regards, Sebastian

I think it is a known issue, and there exist several tickets which kind of relate to this, but I am glad that there is a way to deal with it (adding child docs right from the beginning) (https://issues.apache.org/jira/browse/SOLR-6096, https://issues.apache.org/jira/browse/SOLR-5211, https://issues.apache.org/jira/browse/SOLR-7606)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!