Weekly Report 10 Gsoc @ Moodle

week 10 (17 august- 24 august)

Task 1 (Implementing auto-complete with solr):-

Solr have out of box capability to autocomplete for fields configured in schema. there are many ways to implement the same. there are-

Autocomplete with advance course search

Autocomplete with advance course search

using term component only single term suggestions are possible, and unfortunately we can’t apply any filter. Furthermore, user queries will not be analyzed in any way; you’ll have access to raw indexed data, so won’t be suggest with whitespaces or case-sensitive queries.

so I found SpellCheckComponent as a best solution. This solution has its own separate index which you can automatically build on every commit.

Configuring SpellCheckComponent handler :-

<requestHandler name="/suggest">
    <lst name="defaults">
      <str name="spellcheck">true</str>
      <str name="spellcheck.dictionary">suggest</str>
      <str name="spellcheck.onlyMorePopular">true</str>
      <str name="spellcheck.count">5</str>
      <str name="spellcheck.collate">true</str>
    </lst>
    <arr name="components">
      <str>suggest</str>
    </arr>
  </requestHandler>

Schema.xml :-

<fieldtype name="phrase_suggest" class="solr.TextField">
<analyzer>
<tokenizer class="solr.KeywordTokenizerFactory"/>
<filter class="solr.PatternReplaceFilterFactory"
pattern="([^\p{L}\p{M}\p{N}\p{Cs}]*[\p{L}\p{M}\p{N}\p{Cs}\_]+:)|([^\p{L}\p{M}\p{N}\p{Cs}])+"
replacement=" " replace="all"/>
<filter class="solr.LowerCaseFilterFactory"/>
<filter class="solr.TrimFilterFactory"/>
</analyzer>
</fieldtype>
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s