eZ Community » Forums » Discussions » Solr - Display Spell checker...
expandshrink

Solr - Display Spell checker Suggestions in frontend on Magento CE.

Solr - Display Spell checker Suggestions in frontend on Magento CE.

Tuesday 04 March 2014 12:14:35 pm

Hi,

schema.xml

<field name="textSpell" type="text_general" indexed="true" stored="false" multiValued="true" />

<copyField source="fulltext" dest="textSpell"/>

solrconfig.xml

<searchComponent name="spellcheck" class="solr.SpellCheckComponent">
    <str name="queryAnalyzerFieldType">textSpell</str>
    <lst name="spellchecker">
      <str name="name">default</str>
      <str name="field">textSpell</str>
      <str name="spellcheckIndexDir">./spellchecker</str>
      <str name="buildOnOptimize">true</str>
      <str name="buildOnCommit">true</str>
      <str name="classname">solr.DirectSolrSpellChecker</str>
      <str name="distanceMeasure">internal</str>
      <float name="accuracy">0.5</float>
      <int name="maxEdits">2</int>
      <int name="minPrefix">1</int>
      <int name="maxInspections">5</int>
      <int name="minQueryLength">4</int>
      <!--<float name="maxQueryFrequency">0.01</float>-->
      <!-- uncomment this to require suggestions to occur in 1% of the documents
        <float name="thresholdTokenFrequency">.01</float>
      -->
    </lst>
    <lst name="spellchecker">
      <str name="name">jarowinkler</str>
      <str name="field">textSpell</str>
      <str name="distanceMeasure">org.apache.lucene.search.spell.JaroWinklerDistance</str>
      <str name="spellcheckIndexDir">./spellchecker2</str>
    </lst>
</searchComponent>

<requestHandler name="/spell" class="solr.SearchHandler" startup="lazy">
    <lst name="defaults">
      <str name="df">name</str>
      <str name="spellcheck.dictionary">default</str>
      <str name="spellcheck">on</str>
      <str name="spellcheck.onlyMorePopular">true</str>
      <str name="spellcheck.dictionary">wordbreak</str>
      <str name="spellcheck.extendedResults">true</str>      
      <str name="spellcheck.count">10</str>
      <str name="spellcheck.alternativeTermCount">5</str>
      <str name="spellcheck.maxResultsForSuggest">5</str>      
      <str name="spellcheck.collate">true</str>
      <str name="spellcheck.collateExtendedResults">true</str> 
      <str name="spellcheck.maxCollationTries">10</str>
      <str name="spellcheck">true</str>
      <str name="spellcheck.build">true</str>
      <str name="spellcheck.maxCollations">5</str>        
    </lst>
    <arr name="last-components">
      <str>spellcheck</str>
    </arr>
  </requestHandler>

these are my files And when i search like http://127.0.0.1:8080/solr/spell?q=iphane&spellcheck=true&spellcheck.collate=true&spellcheck.build=true&wt=json&indent=true&rows=0

Response :-

{  "responseHeader":{    "status":0,    "QTime":22},  "command":"build",  "response":{"numFound":0,"start":0,"docs":[]  },  "spellcheck":{    "suggestions":[      "iphane",{        "numFound":2,        "startOffset":0,        "endOffset":6,        "origFreq":0,        "suggestion":[{            "word":"iphone",            "freq":26},          {            "word":"iphon",            "freq":1}]},      "correctlySpelled",false]}}

I want to add this suggestions in my frontend like Did you mean : Iphone   Iphon

Any Ideas ?

Modified on Tuesday 04 March 2014 12:17:07 pm by Nar esh

No reply yet!

expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from