问题描述
我有一个SOLR查询,该查询应获取除一个字段外的所有我存储的字段.
假设我有 20 个字段,是否需要对要在
中获取的 19 个字段进行硬编码&fl=[f],[f],[f],....[f]'
还是有办法做类似
的事情&fl=*,![f]'
I have a SOLR query which should fetch all the fields I store, except one field.
Say I have 20 fields, do I need to hard code the 19 fields I want to fetch in the&fl=[f],[f],[f],....[f]'
Or is there a way to do something similar to&fl=*,![f]'
[f]
代表字段名称.
推荐答案
不幸的是,通过查询字符串删除字段名称的能力仍然是一项突出的改进请求.有关更多详细信息,请参见 SOLR-3191 .
Unfortunately the ability to remove a field name via the query string is still an outstanding improvement request. Please see SOLR-3191 for more details.
在实施此改进之前,您需要在fl
参数中指定所有19个字段.但是,您可以更新默认的/select
requestHandler,以定义要作为默认设置返回的19个字段,该字段将应用于所有查询,除非在查询字符串中将其覆盖.
Until this improvement is implemented, you will need to specify all 19 fields in the fl
parameter. However, you could update your default /select
requestHandler to define the 19 fields that you want to return as a default setting that would be applied to all queries unless it was overridden in the query string.
这是来自示例solrconfig.xml的默认/select
requestHandler的修改版本:
Here is a modified version of the default /select
requestHandler from the example solrconfig.xml:
<requestHandler name="/select" class="solr.SearchHandler">
<!-- default values for query parameters can be specified, these
will be overridden by parameters in the request
-->
<lst name="defaults">
<str name="echoParams">explicit</str>
<int name="rows">10</int>
<str name="df">text</str>
<!-- Only showing 3 fields for this example -->
<str name="fl">field1,field2,field3</str>
</lst>
</requestHandler>
有关这些默认设置和requestHandler配置的更多详细信息,请参考 RequestHandlers和SearchComponents在SolrConfig中.
For more details about these default settings and requestHandler configuration, please refer to RequestHandlers and SearchComponents in SolrConfig.
这篇关于如何在SOLR查询中排除字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!