I am trying to implement Solr context filtering to filter auto-suggestion
result based on the category value.

*schema.xml*

<field name="autosuggest" type="text_spell" indexed="true"
stored="true" multiValued="true" />
<field name="autosuggest_en" type="text_spell_en" indexed="true"
stored="true" multiValued="true" />
<field name="autosuggest" type="text_spell" indexed="true"
stored="true" multiValued="true" />
<copyField source="autosuggest" dest="autosuggest_en" />
<fieldType name="text_spell" class="solr.TextField" positionIncrementGap="100">
            <analyzer>
                <tokenizer class="solr.StandardTokenizerFactory" />
                <filter class="solr.LowerCaseFilterFactory" />
            </analyzer>
</fieldType>
<field name="autosuggest_en" type="text_spell_en" indexed="true"
stored="true" multiValued="true" />
        <fieldType name="text_spell_en" class="solr.TextField"
positionIncrementGap="100">
            <analyzer>
                <tokenizer class="solr.StandardTokenizerFactory" />
                <filter class="solr.PatternReplaceFilterFactory"
pattern="(['’])" replacement=" " />
                <filter class="solr.EnglishMinimalStemFilterFactory" />
                <filter class="solr.StopFilterFactory"
words="lang/stopwords_en.txt" ignoreCase="true" />
                <filter class="solr.ManagedStopFilterFactory" managed="en" />
                <filter class="solr.SynonymFilterFactory"
ignoreCase="true" synonyms="synonyms.txt"/>
                <filter class="solr.ManagedSynonymFilterFactory" managed="en" />
                <filter class="solr.LowerCaseFilterFactory" />
                <filter class="solr.TrimFilterFactory" />
                <filter class="solr.RemoveDuplicatesTokenFilterFactory" />
            </analyzer>
</fieldType>
<dynamicField name="*_string_mv" type="string" indexed="true"
stored="true" multiValued="true" />


*solrConfig.xml*

<lst name="spellchecker">
    <str name="name">categorydic</str>
    <str name="classname">org.apache.solr.spelling.suggest.Suggester</str>
    <str 
name="lookupImpl">org.apache.solr.spelling.suggest.fst.AnalyzingInfixLookupFactory</str>
    <str 
name="dictionaryImpl">org.apache.solr.spelling.suggest.DocumentDictionaryFactory</str>
    <str name="field">autosuggest_en</str>
    <str name="contextField">allCategories_string_mv</str>
    <str name="buildOnStartup">false</str>
    <str name="buildOnCommit">false</str>
    <str name="suggestAnalyzerFieldType">text_spell_en</str>
    <str name="indexPath">${solr.core.dataDir}/suggesttest</str>
</lst>

fields look like

        "spellcheck_en": [
          "ANKITHI LIMIT",
          "ROU7000272",
        ]

"allCategories_string_mv": [
          "3m",
          "harddiskcategory",
          ]


http://localhost:8983/solr/master_Product/suggest?spellcheck=true&spellcheck.build=true&spellcheck.dictionary=categorydic&wt=json&spellcheck.q=mytest&spellcheck.cfq=harddiskcategory

When I am hitting this URL with spellcheck.dictionary=categorydic,
spellcheck.cfq=harddiskcategory,spellcheck.q=mytest it won't filter the
result. I am getting all the match of *mytest*

Solr Version: 5.3.0
Hybris Vesion: 6.0

Any clue?

Regards,
Ankit Patel

Reply via email to