【发布时间】:2017-03-24 08:39:03
【问题描述】:
我正在使用 apache solr-6.0.0
我有一个收藏:我的搜索
每当我运行增量导入时,dataimport.properties 文件中的 last_index_time 都会更新。
有没有办法使用 api 调用来获取这个值?如果是,如何使用 solrj 库读取该值?
使用以下 api 我可以读取文件的内容:
http://localhost:8983/solr/my-search/admin/file?wt=json&file=dataimport.properties
响应看起来像:
#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-stream。但是现在的错误是:
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
【问题讨论】:
-
所以您正在寻找一种将名为
data的属性读入dataimport.properties文件的方法? -
我的意思是我想从这个文件 dataimport.properties 中读取属性“last_index_time”。
-
或者换句话说,我如何使用 solrj 来访问这个 api:localhost:8983/solr/admin/…