奥尔覅几22 发表于 2016-12-14 09:01:21

solr总结 第三部分:solr运行

  才知道之前定的一个标题框架把自己定死了。关于solr总结 第三部分:solr运行,可以讲的地方并不多。
  1.无非就是build成功后,生成索引,访问索引。
  2.生成索引,后文会介绍为数据库数据生成索引。
  3.访问索引,其实就是查询啦。有两种方式:


[*]url直接请求。根据solr查询语法,自己去拼接url,比喻http://localhost:8080/solr/库名/select/?q=solr。举个例子。
/**
* excute solr delta import
* @param strUrl
* @throws AppException
*/
public void doSolrDeltaImport(String strUrl) throws AppException {
URL url = null;
URLConnection con = null;
InputStream is = null;
try {
url = new URL(strUrl);
con = url.openConnection();
con.setAllowUserInteraction(true);
con.setConnectTimeout(36000);
is=con.getInputStream();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally{
try {
if(is != null){
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
 
[*]solrj访问。调用solr提供的API。后文会为大家送上。
页: [1]
查看完整版本: solr总结 第三部分:solr运行