- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在实例上有几个 Solr 核心,每个核心都有一个 StandardRequestHandler
和一些配置的自定义请求处理程序,例如:
<requestDispatcher handleSelect="true" >
<requestParsers enableRemoteStreaming="false" multipartUploadLimitInKB="2048" />
</requestDispatcher>
...
<requestHandler name="standard" class="solr.StandardRequestHandler" default="true" />
...
<requestHandler name="/custom" class="com.example.our.package.CustomHandler" />
...
我希望能够通过 SolrJ 访问它们,但是,我只能通过设置 HttpSolrServer
的 baseUrl
属性来实现> 对象。然而,这是不可取的,因为 HttpSolrServer
实例在多个线程之间共享,因此会出现竞争条件。另一个原因是团队的共识在于 HttpSolrServer
是 Singleton
- 为简单起见。
我试过的是这样的:
HttpSolrServer server = new HttpSolrServer("http://URL_OF_SOLR:PORT/solr/");
SolrQuery query = new SolrQuery();
query.setQueryType("/core/custom");
这适用于自定义处理程序,但是在调用 /select
时失败并显示代码 400,至少对于我尝试过的 URLs (/core
, /core/select
, /core/
, /core/standard
)等
所以我的问题是:我应该如何定义此查询以正确引用核心的默认请求处理程序,仅使用 queryType
或其他一些 SolrParams
值?
最佳答案
您可以在 Solr 中使用 qt
参数来指定特定的请求处理程序,甚至是默认的 /select
处理程序。参见 CoreQueryParameters有关其工作原理的详细信息。 SolrJ 通过在 SolrQuery
类上使用 setRequestHandler
方法来支持这一点。
一些示例,假设您的 Solr 实例位于 http://localhost:8983/solr
并且您有两个名为 core0
和 core1
.
http://localhost:8983/solr/core0/select?q=*:*
默认使用 /select
http://localhost:8983/sole/core1/select?q=*:*&qt=terms
这使用术语 requestHandler
最后,核心名称不应包含在
qt
参数 b/c 中,该参数旨在支持在核心中选择命名的 requestHandler。 Solr 实例的 Url 中应该有核心名称,因为每个核心都是它自己的 Solr 实例,因此应该这样对待,IMO。来自 SolrCore 维基页面:
Multiple cores let you have a single Solr instance with separate configurations and indexes, with their own config and schema for very different applications, but still have the convenience of unified administration.
所以定义多个HttpSolrServer实例。
new HttpSolrServer(http://localhost:8983/solr/core0)
new HttpSolrServer(http://localhost:8983/solr/core1)
关于solr - 使用 setQueryType 通过 SolrJ 访问核心的默认处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17026530/
我在实例上有几个 Solr 核心,每个核心都有一个 StandardRequestHandler 和一些配置的自定义请求处理程序,例如: ... ... ... 我希望能够通过 Solr
我是一名优秀的程序员,十分优秀!