java操作solrAPi时报错。。。
代码:
public class solrQueryTest {
public static void main(String[] args) throws MalformedURLException,SolrServerException {
String baseURL="http://localhost:8983/solr";
SolrServer server=new HttpSolrServer(baseURL);
ModifiableSolrParams params=new ModifiableSolrParams();
params.set("q","平顶山" );
params.set("start", 0);
params.set("rows",5);
params.set("sort", "id desc");
params.set("f1","*");
QueryResponse response=server.query(params);
System.out.println("find"+response.getResults().getNumFound()+"nn");
for(SolrDocument doc:response.getResults()){
System.out.println("id"+doc.getFieldValue("id").toString());
System.out.println("sex"+doc.getFieldValue("sex").toString());
}
}
}
Exception in thread "main" java.lang.NoSuchMethodError: org.apache.http.impl.conn.SchemeRegistryFactory.createSystemDefault()Lorg/apache/http/conn/scheme/SchemeRegistry;
at org.apache.http.impl.client.SystemDefaultHttpClient.createClientConnectionManager(SystemDefaultHttpClient.java:121)
at org.apache.http.impl.client.AbstractHttpClient.getConnectionManager(AbstractHttpClient.java:445)
at org.apache.solr.client.solrj.impl.HttpClientUtil.setMaxConnections(HttpClientUtil.java:201)
at org.apache.solr.client.solrj.impl.HttpClientConfigurer.configure(HttpClientConfigurer.java:33)
at org.apache.solr.client.solrj.impl.HttpClientUtil.configureClient(HttpClientUtil.java:137)
at org.apache.solr.client.solrj.impl.HttpClientUtil.createClient(HttpClientUtil.java:113)
at org.apache.solr.client.solrj.impl.HttpSolrServer.<init>(HttpSolrServer.java:168)
at org.apache.solr.client.solrj.impl.HttpSolrServer.<init>(HttpSolrServer.java:141)
at com.desgin.service.solrQueryTest.main(solrQueryTest.java:15)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
谢谢,,已经解决啦!!!
params.set("q", "来自洛阳的美女"); /*条件也可能是来自河南的美女。。来自河南的18岁美女等*/ 里面包含多个关键词,,这样又是怎么搜索的。。。。
缺jar包 HttpClient