Solr Configuration for providing search suggestions

Hi All,

Today we discuss how we configure solr for provide search suggestion.

For that I follow 2 blogs which are listed below the blog.

Configuring Solr to provide search suggestions

http://www.nttdatasitecore.com/Blog/2017/January/Faceted-Autocomplete-for-a-Sitecore-Multilingual-site-using-SOLR-Suggester-API

By using help of these blog I can configure solr with auto suggest. I use 1st blog for setup solr and using 2nd blog Building jQuery Autocomplete jquery : jquery function for autocomplete suggestion.

Note:

1.Keep in mind while follow first blog for updating solrconfig.xml field str contain the name of the field for example:

<searchComponent name=”suggest” class=”solr.SuggestComponent”>

<lst name=”suggester”>

<str name=”name”>fuzzySuggester</str>

<str name=”field”>page_title_t</str>

</lst>

<lst name=”suggester”>

<str name=”name”>infixSuggester</str>

<str name=”field”>page_title_t</str>

</lst>

</searchComponent>

2. While using 2nd blog jquery function its give cross platform error , solution also provide in that blog but i am not able to resolve that so i use my solution that are below:

$(‘#search-field’).autocomplete({

source: function (request, response) {

var currentLanguage = ‘en’;

var url = “http://localhost:8983/solr/custom_index_autocomplete/suggest?suggest.q=&#8221; + request.term + “&suggest.cfq=” + currentLanguage + “&wt=json&json.wrf=?“;

$.getJSON(url, function (data) {

//response($.map(data.suggest.suggester[request.term].suggestions, function (value) { return value.term }));

response($.map(data.suggest.fuzzySuggester[request.term].suggestions, function (value) { return value.term }));

});

}

});

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