0

I am in process of upgrading content serach Solr provider from Sitecore 8.2 to Sitecore 9.3. I am facing some code issue after upgraded the dll(Sitecore.ContentSearch.SolrProvider, Version=6.0.0.0)

facing issue in creationconnection which is override from Defaultsolr setup

In the upgraded DLL Creationconnection override method does not exits.

public class DefaultSolrStartUp
{
    public DefaultSolrStartUp();
    [Obsolete("Please use the default constructor.")]
    public DefaultSolrStartUp(IHttpWebRequestFactory requestFactory, BaseSolrSpecificSettings solrSettings);

    protected IEnumerable<ISearchIndex> Indexes { get; }
    [Obsolete("The property is not used and will be removed in the future.")]
    protected virtual BaseSolrSpecificSettings SolrSettings { get; }
    [Obsolete("The property is not used and will be removed in the future.")]
    protected virtual IHttpWebRequestFactory RequestFactory { get; }
    protected internal virtual DefaultSolrLocator<Dictionary<string, object>> Operations { get; internal set; }
    [Obsolete("The property is not used and will be removed in the future.")]
    protected internal ISolrConnector SolrConnector { get; set; }

    public virtual void Initialize();
}

Code implementation

public class SolrPostStartUp : DefaultSolrStartUp
{
    protected override ISolrConnection CreateConnection(string serverUrl)
    {
        SolrConnection basecon = new SolrConnection(serverUrl) { Timeout = SolrContentSearchManager.ConnectionTimeout };


        FieldInfo field = typeof(DefaultSolrStartUp).GetField("solrCache", BindingFlags.Instance | BindingFlags.NonPublic);
        var basecache = field.GetValue(this);
        if (basecache != null)
        {
            basecon.Cache = (ISolrCache)basecache;
        }
        PostSolrConnection solrConnection = new PostSolrConnection(basecon, serverUrl);
        return solrConnection;
    }
}

Could someone please suggest the approach for the issue. Thanks in advance

2

Let's firstly define, why do you need it?

It looks like your code forces Solr to use POST requests instead of GET requests. It is usually done to prevent error The remote server returned an error: (414) Request-URI Too Long. This error can appear if you use GET request and have quite a long search query.

If my assumption about the purpose of your code is right then here is the solution. Sitecore 9.3 has ability to turn usage of POST requests on/off from the config file.

  1. Open App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.Solr.DefaultIndexConfiguration.config
  2. Find ContentSearch.Solr.SendPostRequests setting
  3. Set value to be true

And now, you don't need to override any methods in default DefaultSolrStartUp.

P.S. It is better to patch config rather than change it directly.

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.