Java索引json数据到solr
我尝试将json数据索引到solrJava索引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
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的示例 您是在集合中使用架构还是处于无架构模式?它处于无架构模式。