【发布时间】:2016-06-23 12:12:49
【问题描述】:
当我在通过 java 代码索引时将 json 对象发布到 apache solr 6 时,我收到如下错误:
错误信息如下:
"{"元数据":["error-class","org.apache.solr.common.SolrException","root-error-class","org.apache.solr.common.SolrException"],"味精“:”[文档=空] 缺少必填字段:id","code":400}}"
我的json对象如下:
"_childDocuments_" :[
{
"entityname": "ReportDuplicate"
}
],
"_childDocuments_" :[
{
"entityname": "LinkedReport"
}
],
"_childDocuments_" :[
{
"entityname": "Source"
}
],
"_childDocuments_" :[
{
"entityname": "Literature",
"_childDocuments_" :[
{
"entityname": "Authors"
}
]
}
],
"_childDocuments_" :[
{
"entityname": "AdditionalInformation"
}
],
我发布 json 对象的 java 代码如下:
org.apache.http.client.HttpClient client = HttpClientBuilder.create().build();
HttpPost post = new HttpPost("http://localhost:8983/solr/icsr/update/json?wt=json&commit=true");
StringEntity entity = new StringEntity("{\"add\": { \"doc\":"+value+" }}", "UTF-8");
entity.setContentType("application/json");
post.setEntity(entity);
HttpResponse response = client.execute(post);
HttpEntity httpEntity = response.getEntity();
InputStream in = httpEntity.getContent();
String encoding = httpEntity.getContentEncoding() == null ? "UTF-8" : httpEntity.getContentEncoding().getName();
encoding = encoding == null ? "UTF-8" : encoding;
String responseText = IOUtils.toString(in, encoding);
System.out.println("response Text is " + responseText);
我正在使用 solr 6 服务器来索引来自 java 代码的数据: 由于我在调试时遇到错误的 HTTP 请求并且我是 solr 的新手, 并且在 managed-schema.xml 文件中没有进行任何更改: 提前谢谢
【问题讨论】: