Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java索引json数据到solr_Json_Solrj - Fatal编程技术网

Java索引json数据到solr

Java索引json数据到solr,json,solrj,Json,Solrj,我尝试将json数据索引到solr SolrClient solr = new HttpSolrClient.Builder(SOLR_URL).build(); SolrInputDocument document = new SolrInputDocument(); String stringToParse = "{\"id\": \"101\",\"name\": \"Baia Otel\",\"services\":[{\"room_id\":\"1234\",\"service_nam

我尝试将json数据索引到solr

SolrClient solr = new HttpSolrClient.Builder(SOLR_URL).build();
SolrInputDocument document = new SolrInputDocument();
String stringToParse = "{\"id\": \"101\",\"name\": \"Baia Otel\",\"services\":[{\"room_id\":\"1234\",\"service_name\":\"Shuttle\"},{\"room_id\":\"1235\",\"service_name\":\"Accommodation\"}]}";
JSONParser parser = new JSONParser();
try {
    JSONObject json = (JSONObject) parser.parse(stringToParse);
    document.addField("info", json.toJSONString());
} catch (ParseException e) {
    e.printStackTrace();
}
document.addField方法上,如果我使用json.toJSONString()它将json数据索引为字符串,当我只使用jsonObject而不将其强制转换为JSONString时

document.addField("info",json)
它不索引此字段


如何将json索引到solr,以便它将被嵌套索引?

在本文中,您可以找到使用Solrj为无模式solr索引json的示例

您是在集合中使用架构还是处于无架构模式?它处于无架构模式。