Search code examples
postsolrsolrnet

Using POST requests to Solr from SolrNet


Is it possible to send data to Solr using POST instead of GET? I use SolrNet and a Windsor container.


Solution

  • Yes, it's possible. You have to write a decorator around ISolrConnection that POSTs instead of GETs.

    Installing the decorator is very easy in Windsor:

    var container = new WindsorContainer();
    container.Register(Component.For<ISolrConnection>()
        .ImplementedBy<PostSolrConnection>()
        .Parameters(Parameter.ForKey("serverUrl").Eq(serverURL)));
    container.AddFacility("solr", new SolrNetFacility(serverURL));
    

    I blogged exactly about this some time ago (decorator code included)

    UPDATE: PostSolrConnection is now part of the SolrNet library as SolrNet.Impl.PostSolrConnection