调了半天,查了半天,妹的,我终于明白,错是有道理的。
junit测试方法如下:
@Test
public void test01() {
// 创建solrServer对象
try {
CommonsHttpSolrServer server = new CommonsHttpSolrServer(URL);
SolrInputDocument doc = new SolrInputDocument();
doc.addField("id", "1");
doc.addField("msg_title", "这是一个标题");
doc.addField("content", "请注意,这个字段在schema.xml中没有配置,因此下面会报错");
server.add(doc);
server.commit();
} catch (Exception e) {
e.printStackTrace();
}
}
而schema.xml配置文件的配置如下:
少了对content对应的配置。
所以调试的时候会报错:
org.apache.solr.common.SolrException: Bad Request
Bad Request
request: http://localhost:8080/solr/update?wt=javabin&version=2
加上content对应的配置,ko,终于搞定了。。。。。。。。。。。。。。