我想知道我的代码中是否遗漏了某些内容:
public class Main {
private SolrClient client1;
public void run() {
client1 = new HttpSolrClient.Builder("http://localhost:8983/solr").build();
SolrInputDocument doc1 = new SolrInputDocument();
doc1.addField("id", "1");
doc1.addField("type_s", "up");
SolrInputDocument doc2 = new SolrInputDocument();
doc2.addField("id", "2");
doc2.addField("type_s", "down");
doc1.addChildDocument(doc2);
SolrInputDocument doc4 = new SolrInputDocument();
doc4.addField("id", "4");
doc4.addField("type_s", "up");
SolrInputDocument doc5 = new SolrInputDocument();
doc5.addField("id", "5");
doc5.addField("type_s", "down");
doc4.addChildDocument(doc5);
try {
client1.add("techproducts", Arrays.asList(doc1,doc4));
} catch (Exception e) {
System.out.println("Indexing failed" + e);
}
}
如果我使用bin / start start -e techproduct启动Solr 6.3并询问以下内容:
然后我得到:
{
"docs": [
{
"id": "2",
"type_s": "down"
},
{
"id": "5",
"type_s": "down",
"_childDocuments_": [
{
"id": "1",
"type_s": "up"
}
]
}
]
}
这对我来说似乎是个错误。或者我错过了什么?
请注意,关系" 2是1"的孩子。和" 5是4"工作正常。只是我得到额外的(不需要的)关系。