In my experience, trying to get ExtraParam
to work with the Sitecore.ContentSearch
especially in 8.*
has been unfruitful (tried getting grouping to work on groupId with no luck) as the ExtraParams
along with a lot of other SolrNet
pieces are locked down an unexposed through the api. I used a different approach (in unrelated functionality to the grouping bit) to invoke the suggest
handler in Solr (repurposed below):
var index = ContentSearchManager.GetIndex((SitecoreIndexableItem)contextDataItem);
var serviceUrl = SolrContentSearchManager.ServiceAddress.TrimEnd('/');
var handler = "/elevate";
IEnumerable<string> results = null;
var solrUrl = string.Format("{0}/{1}", serviceUrl, index.Name);
var solrConnection = new SolrConnection(solrUrl);
var parameters = new Dictionary<string, string>();
parameters.Add("q", searchTerm);
parameters.Add("enableElevation", "true");
parameters.Add("forceElevation", "true");
parameters.Add("df", "text");
parameters.Add("wt", "xml");
var xmlResponse = solrConnection.Get(handler, parameters);
var xmlDocument = new XmlDocument();
xmlDocument.LoadXml(xmlResponse);
//parse the returned xml into proper results
results = _parseSuggestion(xmlDocument, suggestionType).ToList();
return results;
Which would invoke something like http://localhost:8983/solr/your_products_master/elevate?q=ipod&df=text&debugQuery=true&enableElevation=true&forceElevation=true
I realize that this approach pretty much circumvents using Predicate Builder
or really any of the ContentSearch
api already in place. In Sitecore 9 I believe they opened up a lot of the api to allow for passing QueryOptions
and possibly ExtraParams
as well (have not had a chance to confirm). Hopefully this helps even if only a little.