我已经实现了一个 Solr 建议处理程序来处理来自我的应用程序的自动完成建议。但是,我需要能够根据用户权限过滤这些结果。本质上,这可以确保返回的字段之一与键(例如用户名)匹配。
我的架构如下所示(自动完成字段):
<!-- suggest fields -->
<field name="name_suggest" type="text_suggest" indexed="true" stored="false" multiValued="true" />
<field name="name_suggest_suggest_edge" type="text_suggest_edge" indexed="true" stored="false" multiValued="true" />
<field name="name_suggest_suggest_ngram" type="text_suggest_ngram" indexed="true" stored="false" multiValued="true" />
<field name="name_suggest_s" type="alphaNumericSort" indexed="true" stored="false" multiValued="true" />
<!-- copy fields -->
<copyField source="firstName" dest="name_suggest" />
<copyField source="firstName" dest="name_suggest_suggest_edge" />
<copyField source="firstName" dest="name_suggest_suggest_ngram" />
<copyField source="firstName" dest="name_suggest_s" />
<copyField source="lastName" dest="name_suggest" />
<copyField source="lastName" dest="name_suggest_suggest_edge" />
<copyField source="lastName" dest="name_suggest_suggest_ngram" />
<copyField source="lastName" dest="name_suggest_s" />
<copyField source="id" dest="customerID" />
SolrConfig中的建议处理程序:
!-- request handler to return typeahead suggestions -->
<requestHandler name="/suggest" class="solr.SearchHandler">
<lst name="defaults">
<str name="echoParams">explicit</str>
<str name="defType">edismax</str>
<str name="rows">10</str>
<str name="fl">firstName, lastName, address1, customerID,score</str>
<str name="qf">name_suggest^30 name_suggest_suggest_edge^50.0</str>
<str name="pf">name_suggest_suggest_edge^50.0</str>
<str name="group">false</str>
<str name="group.field">name_suggest_s</str>
<str name="sort">score desc</str>
<str name="group.sort">score desc</str>
</lst>
</requestHandler>
如何过滤来自此处理程序的结果(最好不必在内存消费者端进行)?