Java Solr以编程方式获取最后一个索引时间
我正在使用ApacheSolr-6.0.0 我有一个收藏:我的搜索 每当我运行增量导入时,dataimport.properties文件中的最后一次索引时间都会得到更新 有没有办法使用api调用获取此值?如果是,如何使用solrj库读取该值 使用以下api,我能够读取文件的内容: 答复如下:Java Solr以编程方式获取最后一个索引时间,java,solr,solrj,Java,Solr,Solrj,我正在使用ApacheSolr-6.0.0 我有一个收藏:我的搜索 每当我运行增量导入时,dataimport.properties文件中的最后一次索引时间都会得到更新 有没有办法使用api调用获取此值?如果是,如何使用solrj库读取该值 使用以下api,我能够读取文件的内容: 答复如下: #Thu Mar 23 10:00:01 UTC 2017 name.last_index_time=2017-03-23 10\:00\:01 last_index_time=2017-03-23 10
#Thu Mar 23 10:00:01 UTC 2017
name.last_index_time=2017-03-23 10\:00\:01
last_index_time=2017-03-23 10\:00\:01
使用solrj java库,我将执行以下操作:
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("qt", "/admin/file");
params.set("file", "dataimport.properties");
params.set("contentType", "text/plain;charset=utf-8");
try
{
return this.solr.query(collectionName, params);
}
catch (Exception e)
{
logger.info("Exception msg: " + e.getMessage());
}
但我说的是错误的:
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/cdi-search: Expected mime type application/octet-stream but got text/plain. #Thu Mar 23 10:00:01 UTC 2017
name.last_index_time=2017-03-23 10\:00\:01
last_index_time=2017-03-23 10\:00\:01
我将contentType更改为application/octet流。但现在的错误是:
org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException: Error from server at http://localhost:8983/solr/cdi-search: Invalid version (expected 2, but 35) or the data in not in 'javabin' format
这使得添加、更新和查询Solr集合变得很容易。换句话说,索引文档并搜索它们
不包括您正在谈论的功能类型
您所需要的只是提交一个HTTP请求,下载资源,读取并解析它。我建议阅读本Java教程“”
因此,您正在寻找一种将名为
data
的属性读入dataimport.properties
文件的方法?我的意思是我想从这个文件dataimport.properties中读取属性“last_index_time”。或者换句话说,我如何使用solrj点击这个api:
URL oracle = new URL("http://localhost:8983/solr/admin/zookeeper?detail=true&path=%2Fconfigs%2Fmy-search%2Fdataimport.properties");
BufferedReader in = new BufferedReader(
new InputStreamReader(oracle.openStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();