简体   繁体   中英

Session id to the Solr url

I am trying to send a query to a server running Solr as follows:

String solrServerUrl = //SomeBaseUrl
CommonsHttpSolrServer searchServer = new CommonsHttpSolrServer("http://"+solrServerUrl);
QueryResponse result = searchServer.query(query,SolrRequest.METHOD.POST);

In the query request that I send over to the Solr server,I append the sessionId string as follows(for logging purposes):

String solrServerUrl = SomeBaseUrl.concat("?sessionId");

When I run the server, I get the following exception:

nested exception is java.lang.RuntimeException: Invalid base url for solrj. The base URL must not contain parameters

Can somebody point out how I can forward the unique session-id to the Solr server so that the session-id is picked by the tomcat valves set up in the destination Solr-server for logging purposes?

Thanks

I don't think it's possible that way with the actual CommonsHttpSolrServer code, it doesn't matter if you're using POST or GET (even if rfeak's comment looks good).

There's a condition like this in the main CommonsHttpSolrServer constructor:

if( _baseURL.indexOf( '?' ) >=0 ) {
    throw new RuntimeException( "Invalid base url for solrj.  The base URL must not contain parameters: "+_baseURL );
}

I would try using the SolrQuery#setParam method. This way you might be able to add additional request parameters, which should just be ignored by the Solr request handler.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM