I have a question about solrnet, and more specifically about mapping fields to C# objects.
I have the following code:
var mgr = new MappingManager();
mgr.Add(typeof(Article).GetProperty("Title"), "newsTitle");
SolrServerElement news = new SolrServerElement();
news.Id = "news";
news.DocumentType = typeof(Article).AssemblyQualifiedName;
news.Url = "http://127.0.0.1:8080/solrNews/news";
SolrServers servers = new SolrServers();
servers.Add(news);
ObjectFactory.Initialize(
x =>
{
x.AddRegistry(
new SolrNetRegistry(servers)
);
x.For<IReadOnlyMappingManager>().Use(mgr);
}
);
_solr = ObjectFactory.GetInstance<ISolrOperations<Article>>();
_solr.Ping();
It does not appear to map the solr fields to the object properties in C#. Any ideas?
In order to get the MappingManager working correctly you need to eject IReadOnlyMappingManager from ObjectFactory first of all, and then configure it to use your own MappingManager.
So it would be something like this: