I recently tried solr autosuggest search in my local,
Steps I followed :
Added configuration in master in sensoft_master_index\conf\solrconfig.xml
Restarted solr8.1 service in services
- in C# code,
public IEnumerable GetSuggestion(string term) {
try
{
using (var context = ContentSearchManager.GetIndex("sitecore_master_index").CreateSearchContext())
{
SolrSuggestQuery query = term;
var options = new SuggestHandlerQueryOptions
{
Parameters = new SuggestParameters
{
Count = 3
}
};
var result = context.Suggest(query, options);
return result.Suggestions["default"].Suggestions.Select(a => a.Term);
}
}
catch (Exception e)
{
System.IO.File.WriteAllText(@"D:\test1.txt", e.ToString());
}
return rr;
}
I'm getting the results But now I want to filter the suggestion only from a particular path: for ex: I need the suggestions that have the path: /sitecore/content/home
what configuration changes I need to make? Any help