[英]Session id to the Solr url
I am trying to send a query to a server running Solr as follows: 我试图将查询发送到运行Solr的服务器,如下所示:
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): 在我发送给Solr服务器的查询请求中,我按如下方式附加sessionId字符串(出于记录目的):
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.
嵌套的异常是java.lang.RuntimeException:solrj的无效基本URL。 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? 有人可以指出我如何将唯一的会话ID转发到Solr服务器,以便由目标Solr服务器中设置的tomcat阀选择会话ID以便进行日志记录?
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). 我认为实际的
CommonsHttpSolrServer
代码不可能这样,无论您使用的是POST还是GET(即使rfeak的注释看起来不错)也没关系。
There's a condition like this in the main CommonsHttpSolrServer
constructor: 在
CommonsHttpSolrServer
主构造函数中有一个这样的条件:
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. 我会尝试使用
SolrQuery#setParam
方法。 This way you might be able to add additional request parameters, which should just be ignored by the Solr request handler. 这样,您也许可以添加其他请求参数,Solr请求处理程序应该忽略这些参数。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.