5

As the question says; do I have any options of setting/defining my own Search- and Request-Handlers for Sitecore ContentSearch, based on the active site?

Skimming through ContentSearch configs, I'm not even sure where the default SearchHandler is defined, much less if there is code anywhere than I can hook into, to control it.

Example:

Scenario could be; where we have say /products and /productsinstock search handlers; where the latter one would - as an example - the following filter added.

<lst name="appends">
  <str name="fq">inStock:true</str>
</lst>
6
  • If I'm understanding your ask correctly, multiple cores would not suit your need. As such, creating a distributed/clustered/federated farm would not do. Instead, you are looking more for a way to have multiple instances so that if you have one site in the US, another in Germany, and one in Australia, you can have a solr instance for each site that is on a server in the same region of the site. Correct? – Zachary Kniebel Oct 17 '16 at 14:13
  • Expanded question to clarify. – Mark Cassidy Oct 17 '16 at 15:26
  • It sounds like you're looking for how to manage your solr cores, which you create in the Solr admin and can add custom configurations for in the code. – Zachary Kniebel Oct 17 '16 at 15:45
  • No. All in one core. – Mark Cassidy Oct 17 '16 at 16:14
  • 2
    so out of the box it is not possible to use different search handler through Sitecore SOLR content search. Sitecore's SOLR implementation is based on SOLR.NET, which hard codes the search handler to use in the "SolrQueryExecuter" class. You could implement your own executer class an patch it through the IOC container you are using. however this will not give you the option to choose which one to use on query time. – Semion Mc Alice Oct 17 '16 at 18:21
2

So out of the box it is not possible to use different search handler through Sitecore SOLR content search. Sitecore's SOLR implementation is based on SOLR.NET, which hard codes the search handler to use in the "SolrQueryExecuter" class.

/// <summary>
/// Default Solr query handler
/// </summary>
public static readonly string DefaultHandler = "/select";

The DefaultHandler to use from the SolrQueryExecuter class. The original code can be found here. https://github.com/mausch/SolrNet/blob/master/SolrNet/Impl/SolrQueryExecuter.cs

You could implement your own executer class an patch it through the SolrNET Startup container you are using.

 Register<ISolrQueryExecuter<T>>(c => new SolrQueryExecuter<T>(c.GetInstance<ISolrAbstractResponseParser<T>>(), connection, c.GetInstance<ISolrQuerySerializer>(), c.GetInstance<ISolrFacetQuerySerializer>(), c.GetInstance<ISolrMoreLikeThisHandlerQueryResultsParser<T>>()));

The initialization code for the default SolrQueryExecuter do in the SolrNET.Startup.Init method. The Original code can be found here: https://github.com/mausch/SolrNet/blob/master/SolrNet/Startup.cs

The SolrNET.Startup.Container is a public property, and thus can be altered.

However this will not give you the option to choose which one to use on query time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.