0

所以我有一个在 solr 中索引的数据库,我正在尝试使用 ContextField/cfq 过滤搜索建议(建议)。我想要做的是将建议查询过滤到上下文字段(布尔字段)设置为 false 或没有字段的元素。仅使用 false 不起作用,我不确定如何在 solrconfig.xml 中的Suggest.cfq 字段中制定它,因为该字段已被声明为上下文字段,而且我似乎无法做到 (-myfield:[* TO *] AND : ) 或 myfield:false . 如何做我想做的事?

solrconfig.xml 的相关块:

<searchComponent name="suggest" class="solr.SuggestComponent">
 <lst name="suggester">
    <str name="name">composerSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/composerSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">composers_searchable</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
 <lst name="suggester">
    <str name="name">pieceSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/pieceSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">pieces_searchable</str>
    <str name="weightField">price</str>
    <str name="contextField">hidden</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
 <lst name="suggester">
    <str name="name">collectionSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/collectionSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">collections_searchable</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
 <lst name="suggester">
    <str name="name">languageSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/languageSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">languages_searchable</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
 <lst name="suggester">
    <str name="name">genreSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/genreSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">genres_searchable</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
 <lst name="suggester">
    <str name="name">locationSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/locationSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">locations_searchable</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
 <lst name="suggester">
    <str name="name">sourceSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/sourceSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">sources_searchable</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
 <lst name="suggester">
    <str name="name">instrumentSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/instrumentSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">instruments_voices_searchable</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
 <lst name="suggester">
    <str name="name">tagSuggest</str>
    <str name="lookupImpl">AnalyzingInfixLookupFactory</str>
    <str name="indexPath">suggestions/tagSuggest_dict</str>
    <str name="dictionaryImpl">DocumentDictionaryFactory</str>
    <str name="field">tags_searchable</str>
    <str name="weightField">price</str>
    <str name="suggestAnalyzerFieldType">suggestTypeLc</str>
    <str name="buildOnStartup">true</str>
    <str name="buildOnCommit">false</str>
    <str name="highlight">false</str>
 </lst>
</searchComponent>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy" >
 <lst name="defaults">
   <str name="suggest">true</str>
   <str name="suggest.count">15</str>
   <str name="suggest.cfq">(-hidden:[* TO *] AND *:*) OR hidden:false</str>
</lst>
<arr name="components">
  <str>suggest</str>
</arr>

4

1 回答 1

0

希望它可以帮助某人。

contextField在建议器组件中指定(pieceSuggest suggester在您的情况下)。<str name="contextField">hidden</str>cfq字段值更改为requestHandler

 <str name="suggest.cfq">-true</str>

它应该给出所有具有false或没有字段值的建议hidden字段

于 2017-04-13T14:48:17.940 回答