Solr 7 强制 q 值

Solr 7 Forcing q value

我正在使用 Drupal ApacheSolr Multisite Module which due to it's dependency Apache Solr Search 配置,目前仅支持 Solr 5.x。我正在使用 Solr 7 并更新了大部分配置。除了 /select,我的一切都正常工作。我相信这是因为模块提供的查询(如下所示的示例)具有 "q" 值,这显然会导致它失败。 solrconfig.xml 中有没有办法为所有 select 设置 q 等于“*.*”?如果可能的话,我想避免对 Drupal 模块本身进行代码更改。

Solar REST 请求示例

http://localhost:8983/solr/drupal_multisite/select?start=0&rows=10&fq=%28hash%3A6qegyq%20OR%20access__all%3A0%29&fq=%28hash%3A6qegyq%29&spellcheck=true&q=test&fl=id%2Centity_id%2Centity_type%2Cbundle%2Cbundle_name%2Clabel%2Css_language%2Cis_comment_count%2Cds_created%2Cds_changed%2Cscore%2Cpath%2Curl%2Cis_uid%2Ctos_name%2Chash%2Csite&mm=1&pf=content%5E2.0&ps=15&hl=true&hl.fl=content&hl.snippets=3&hl.mergeContigious=true&f.content.hl.alternateField=teaser&f.content.hl.maxAlternateFieldLength=256&spellcheck.q=test&qf=content%5E40&qf=label%5E5.0&qf=tags_h1%5E5.0&qf=tags_h2_h3%5E3.0&qf=tags_h4_h5_h6%5E2.0&qf=tags_inline%5E1.0&qf=tos_content_extra%5E0.1&qf=tos_name%5E3.0&qf=ts_comments%5E20&wt=json&json.nl=map

solarconfig.xml 例子

<requestHandler name="/select" class="solr.SearchHandler">
 <lst name="defaults">
  <str name="df">text</str>
  <str name="q">*:*</str>
  <str name="q.alt">*:*</str>
 </lst>
</requestHandler>

感谢您的任何建议!

如果您可以编写一些代码(不在 drupal 模块中,而是一个独立的 class/jar),那么您可以编写一个 solr 插件(https://wiki.apache.org/solr/SolrPlugins) and write a custom handler for "/select" (https://medium.com/@wkaichan/custom-request-handler-in-apache-solr-4f76521b031a)并在该处理程序中覆盖 "q" 参数为“.”并调用原始处理程序。

可以从您自己的 drupal 模块更改查询,Apache Solr 搜索模块为此公开了一个挂钩 (hook_apachesolr_query_alter):

/**
 * Implementation of hook_apachesolr_query_alter().
 * 
 * @param DrupalSolrQueryInterface $query
 * @see apachesolr.interface.inc
 */
function yourmodule_apachesolr_query_alter(DrupalSolrQueryInterface $query) {
  $query->replaceParam('q', '*:*');
}

也就是说,如果您 "got everything working except on /select",您的问题可能与您的请求调度程序的 handleSelect 参数有关,该选项会影响诸如 /select?qt=XXX 之类的请求(如果您不明白我的意思,请阅读 )。