0
votes

I am trying to filter using a contextField in Solr 7.2. In solrconfig.xml I have the following:

<searchComponent name="suggest" class="solr.SuggestComponent">
   <lst name="suggester">
      <str name="name">suggest_artist</str>
      <str name="lookupImpl">BlendedInfixLookupFactory</str>
      <str name="dictionaryimpl">DocumentDictionaryFactory</str>
      <str name="field">artist</str>
      <str name="weightField">monthly_dlds</str>
      <str name="contextField">territory</str>
      <str name="queryAnalyzerFieldType">phrase_suggest</str>
      <str name="suggestAnalyzerFieldType">text_suggest</str>
      <str name="buildOnStartup">true</str>
      <str name="buildOnCommit">true</str>
      <str name="storeDir">suggest_a</str>
      <str name="indexPath">suggest_a</str>
      <str name="highlight">false</str>
   </lst>
<requestHandler name="/suggest" class="solr.SearchHandler" startup="lazy">
  <lst name="defaults">
      <str name="echoParams">all</str>
      <str name="wt">json</str>
      <str name="indent">true</str>
    <str name="suggest">true</str>
    <str name="suggest.count">10</str>
  </lst>
  <arr name="components">
    <str>suggest</str>
  </arr>
</requestHandler>

In my schema, the territory field is configured as follows:

<field name="territory" type="string" indexed="true" stored="true" multiValued="true"/>

The territory field is multivalued, containing territories (['US', 'CA', etc.]).

I run the suggest query as follows:

http://localhost:8983/solr/test_suggester/suggest?suggest.dictionary=suggest_artist&suggest.q=m&suggest.cfq=US

and I get a response with no suggestions found.

{
  "responseHeader":{
    "zkConnected":true,
    "status":0,
    "QTime":0,
    "params":{
      "echoParams":"all",
      "indent":"true",
      "suggest.q":"m",
      "suggest.count":"10",
      "suggest":"true",
      "suggest.dictionary":"suggest_artist",
      "wt":"json",
      "suggest.cfq":"US"}},
  "suggest":{"suggest_artist":{
      "m":{
        "numFound":0,
        "suggestions":[]}}}}

Without the suggest.cfg=US I am getting a list of suggestions (I have checked that there are items that should be returned by searching using fq=territory:US). I have tried using a single-valued field, using both boolean (eg: us_terr:true) and string field-types (us_terr:"t"), and the results have been the same. The suggester is in its own separate collection on SolrCloud, with only one shard.

1

1 Answers

0
votes

The issue was a that dictionaryImpl was misspelt.

<str name="dictionaryimpl">DocumentDictionaryFactory</str>

should be:

<str name="dictionaryImpl">DocumentDictionaryFactory</str>

This meant that it was using the default dictionary implementation, HighFrequencyDictionaryFactory, which doesn't support context filtering.