1

I am using Solr.NET within my application. Within the application, I need to connect to two different solr servers. Both of these solr servers return the same type of document, let's call the document type Foo.

Also, I need to use a custom connection so that all queries are always POSTed to solr.

Here is what I have so far:

StartUp.Init<Foo>(new PostOnlyConnection(connectionString1))
StartUp.Init<Foo>(new PostOnlyConnection(connectionString2))

Obviously, the IoC container throws an error on this since the two types are the same. I tried to resolve this issue with the information located in this article, but the Windsor facility does not allow me to pass in a custom connection object, just the connection string. Any ideas?

jmacinnes
  • 1,589
  • 1
  • 11
  • 21

2 Answers2

2

It looks like you're still using the built in container (Startup) which is limited to different document types. The article you posted contains an example for Windsor.

I am not too familiar with Windsor but you should be able to reregister ISolrConnection with your custom PostOnlyConnection.

References:

Explaination of SolrNet connection

Community
  • 1
  • 1
Jerry Wang
  • 588
  • 5
  • 6
0

If the Windsor option is not working, you could create 2 classes that inherits from the same class just to init a solr connection with a different type.

class Foo {}
class FooA : Foo {}
class FooB : Foo {}

StartUp.Init<FooA>(new PostOnlyConnection(connectionString1))
StartUp.Init<FooB>(new PostOnlyConnection(connectionString2))

I have more than 1 core and this is the solution I use. It creates some challenges, meaning that you will need some template methods to query data in each solr instance.

Dorin
  • 2,482
  • 2
  • 22
  • 38