The Wayback Machine - https://web.archive.org/web/20201029105012/https://github.com/SolrNet/SolrNet/issues/459
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SolrNet using plain SolrConnection when AutoSolrConnection injected with Windsor #459

Open
Seebiscuit opened this issue Dec 6, 2018 · 2 comments

Comments

@Seebiscuit
Copy link

@Seebiscuit Seebiscuit commented Dec 6, 2018

In our project we handle SolrNet operations through a repository which we instantiate like this:

//Our project deploys one "case" per client and each client has their own Solr core
//which we name based on their "caseId"
public SolrSearchRepository(int caseId, string solrServer)
{
    var coreName = "core_" + caseId;

    this.container = new WindsorContainer();
    this.container.Register(Component.For<ISolrConnection>()
                .ImplementedBy<AutoSolrConnection>()
                .DependsOn(Parameter.ForKey("serverUrl").Eq(solrServer)));

    this.facility = new SolrNetFacility(solrServer);
    this.facility.AddCore(coreName, typeof(SolrDocument), solrServer + "/" + caseId);

    this.container.AddFacility(this.facility);

    solrOperation = this.container.Resolve<ISolrOperations<SolrDocument>>(coreName);
}

Where ISolrConnection is implemented by the AutoSolrConnection class @gjunge recently contributed.

With this setup SolrNet is still using a GET request when sending queries.

I looked deeper into the matter and luckily I found this:

public void AddCore(Type documentType, string coreUrl, bool postConnection = false)

where I noticed that AddCore takes a postConnection parameter. Supplying a true value for the postConnection param toggled a POST request for queries.

I was thus able to reduce my core setup to:

//Our project deploys one "case" per client and each client has their own Solr core
//which we name based on their "caseId"
public SolrSearchRepository(int caseId, string solrServer)
{
    var coreName = "core_" + caseId;

    this.container = new WindsorContainer();

    this.facility = new SolrNetFacility(solrServer);
    this.facility.AddCore(coreName, typeof(SolrDocument), solrServer + "/" + caseId);

    this.container.AddFacility(this.facility);

    solrOperation = this.container.Resolve<ISolrOperations<SolrDocument>>(coreName);
}

I have the following questions and comments:

  1. Since I'm using the SolrnetFacility does that override any components I register on the WindsorContainer? If yes, how could I use AutoSolrConnection?
  2. There is no documentation on how to implement SolrPostConnection on a multi-core setup.
  3. There is no documentation on AutoSolrcConnection

For comments 2) and 3) I'd be happy to push a PR if there's interest.

@xmorera
Copy link
Member

@xmorera xmorera commented Dec 6, 2018

Regarding documentation, please contribute as much as possible. For the other question, perhaps @gjunge may have an answer.

@gjunge
Copy link
Member

@gjunge gjunge commented Dec 12, 2018

AutosolrConnection has not been added to the other DI containers. I'm not really familiar with Windsor, so I wouldn't be able to tell you what takes presedence. I do think it might be good to change the implementation, and by default use the AutoSolrConnection.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.