You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Billy Newman <ne...@gmail.com> on 2012/11/06 21:59:33 UTC

Access DIH from inside application (via Solrj)?

I know that you can access the DIh interface restfully which work
pretty well for most cases.  I would like to know however if it is
possible to send/receive commands from a DIH vai the Solrj library.
Basically I would just like to be able to kick off the DIH and maybe
check status.  I can work around this but java is not the best client
for handling/dealing with http/xml.  If I could use Solrj the code
would probably be a lot more straight forward.

Thanks guys/gals,

Billy

RE: Access DIH from inside application (via Solrj)?

Posted by "Dyer, James" <Ja...@ingramcontent.com>.
DIH & SolrJ don't really support what you want to do.  But you can make it work with code like this, which reloads the DIH configuration and checks for the response.  Just note this is quite brittle:  whenever the response changes in future versions of DIH, it'll break your code.

Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("command", "reload-config");
SolrParams params = new MapSolrParams(paramMap);
DirectXmlRequest req = new DirectXmlRequest("/dataimporthandler", null);		
req.setMethod(METHOD.GET);
req.setParams(params);
NamedList<Object> nl = server.request(req);
String importResponse = (String) nl.get("importResponse");
boolean reloaded = false;
if("Configuration Re-loaded sucessfully".equals(importResponse)) {
	reloaded = true;
}

James Dyer
E-Commerce Systems
Ingram Content Group
(615) 213-4311


-----Original Message-----
From: Billy Newman [mailto:newmanw10@gmail.com] 
Sent: Tuesday, November 06, 2012 3:00 PM
To: solr-user@lucene.apache.org
Subject: Access DIH from inside application (via Solrj)?

I know that you can access the DIh interface restfully which work
pretty well for most cases.  I would like to know however if it is
possible to send/receive commands from a DIH vai the Solrj library.
Basically I would just like to be able to kick off the DIH and maybe
check status.  I can work around this but java is not the best client
for handling/dealing with http/xml.  If I could use Solrj the code
would probably be a lot more straight forward.

Thanks guys/gals,

Billy