Please help me with this error "Key 'SolrNet.Impl.SolrConnection.Testing.Review.SolrNet.Impl.SolrConnection' already registered in container"

1,407 views
Skip to first unread message

MrBurn

unread,
Jun 28, 2011, 5:26:21 PM6/28/11
to SolrNet
This is my code:

public static ICollection<Review> ShowingData(string searchString)
{
// DataTable dt = new DataTable();
Startup.Init<Review>("http://localhost:8080/solr");
ISolrOperations<Review> solr =

ServiceLocator.Current.GetInstance<ISolrOperations<Review>>();
/* issue a lucene query */

ICollection<Review> results =
solr.Query(searchString);
return (results);
}

basically I called this function when I do the search. The first time
searching is ok but if I search again it will give me the error.

Thank you so much.

Mauricio Scheffer

unread,
Jun 28, 2011, 5:29:28 PM6/28/11
to sol...@googlegroups.com
Startup.Init must only be called once at app startup. See http://code.google.com/p/solrnet/wiki/Initialization for reference.

--
Mauricio




--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To post to this group, send email to sol...@googlegroups.com.
To unsubscribe from this group, send email to solrnet+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/solrnet?hl=en.


less...@gmail.com

unread,
Jun 17, 2013, 3:00:04 PM6/17/13
to sol...@googlegroups.com
What if I need to allow multiple threads to search simultaneously? I can't simply share the same _solr variable as it's very stateful.

On Friday, December 7, 2012 12:26:52 PM UTC-2, Renso Hollhumer wrote:
Simply declare solr var as static variable in test class

        private static ISolrOperations<SolrDocument> _solr;

        [ClassInitialize()]
        public static void MyClassInitialize(TestContext testContext)
        {
            Startup.Init<SolrDocument>("http://localhost:8983/solr");
            _solr = ServiceLocator.Current.GetInstance<ISolrOperations<SolrDocument>>();

        }

Mauricio Scheffer

unread,
Jun 17, 2013, 3:16:51 PM6/17/13
to sol...@googlegroups.com
You can safely share an instance of ISolrOperations<SolrDocument>


--
Mauricio


--
You received this message because you are subscribed to the Google Groups "SolrNet" group.
To unsubscribe from this group and stop receiving emails from it, send an email to solrnet+u...@googlegroups.com.

To post to this group, send email to sol...@googlegroups.com.
Visit this group at http://groups.google.com/group/solrnet.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Oscar Gomez Mateu

unread,
Jul 17, 2013, 6:28:09 AM7/17/13
to sol...@googlegroups.com
I need to 'restart' the Solr instance when the user modifies the config (the solr URL). Otherwise the index calls are done to the 'old' solr URL. Any idea how can this be achieved?

Op maandag 17 juni 2013 21:16:51 UTC+2 schreef Mauricio Scheffer het volgende:

Mauricio Scheffer

unread,
Jul 19, 2013, 12:37:11 AM7/19/13
to sol...@googlegroups.com
The safest choice would be to rebuild the entire SolrNet object graph with the new Solr URL.
Alternatively, you could get the ISolrConnection instance, cast it down to SolrConnection and set the ServerURL property. But I wouldn't recommend that unless you really know what you're doing.

Also, may I ask why a user can change the Solr URL? What do you want to achieve with that?


--
Mauricio
Reply all
Reply to author
Forward
0 new messages