1

Im using apache Solr for my site search. and the website has large number of pages and each page has a field called 'searchEnabled'. This is a boolean field contains values true or false. I want to exclude the disabled pages from all the search results (The site has number of different searches) if the searchEnabled field is set to false.

I can use a filter query(fq) to exclude this field. But my site is using number of different searches with different queries. I do not want to add the filter query in all the search queries across the website. Is there any easy way to disable the indexes with field 'searchEnabled' set to false?

So that no any solr search will return the document/pages where the field value is set to false.

4

1 回答 1

3

solrconfig.xml您可以为您提出请求的请求处理程序添加一个始终存在的参数。

通过使用appends参数列表的名称,该参数将始终附加到其他给定参数。

<requestHandler name="/select" class="solr.SearchHandler">
  <lst name="appends">
    <str name="fq">searchEnabled:true</str>
  </lst>
</requestHandler>

这将始终在后台向您的请求添加过滤器查询,将结果集限制为那些已searchEnabled设置为true.

于 2020-08-04T19:51:54.190 回答