0
votes

I am using apache solr-6.0.0

I have a collection : my-search

whenever I run a delta-import, the last_index_time in the dataimport.properties file is getting updated.

Is there a way to get this value using an api call? and if Yes how can that value be read using solrj library?

using the following api I am able to read the content of the file:

http://localhost:8983/solr/my-search/admin/file?wt=json&file=dataimport.properties

The response looks like :

#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

using solrj java library, I am doing the following:

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());
}

But I am getting error saying:

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

I changed the contentType to application/octet-stream. But now the error is :

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
1
So you're looking for a way to read the property named data into the dataimport.properties file? - freedev
I mean I want to read the property "last_index_time" from this file dataimport.properties. - iwekesi
Or In other words, how can I hit this api using solrj: localhost:8983/solr/admin/… - iwekesi

1 Answers

0
votes

SolrJ is an API that makes it easy to add, update, and query the Solr collections. In other words indexing documents and search them.

Does not cover the kind of feature you're talking about.

All you need is just submit an HTTP request, downloaded your resource, read and parse it. I suggest to read this Java tutorial "Reading directly from a URL".

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();