Have index mapped to an interface.

14 views
Skip to first unread message

Kasturi Chavan

unread,
Sep 15, 2015, 12:46:05 PM9/15/15
to SolrNet
Hi Everyone, Im fairly new to use of solr and solrnet. I had a question 

var solrFacility = new SolrNetFacility(ConfigurationSettings.ContentSearch_Solr_ServiceBaseAddress);
solrFacility.AddCore(AgentsIndexName.IndexName, typeof(AgentsIndex), ConfigurationSettings.ContentSearch_Solr_ServiceBaseAddress +"/"+ AgentsIndexName.IndexName);
IOC.Container.AddFacility("solr", solrFacility);

Following is the code I have written. the index is mapped to a class named AgentsIndex. Can I map this to its interface?
Would that be a good practice?

I wanna map it to an interface so I can use my generic crawler.

public abstract class Crawler<T> : ICrawler<T>
{
                public void RebuildIndex(ISolrOperations<T> indexOperations, IEnumerable<T> indexMapper)
{
}
}


public class AgentsIndexCrawler : Crawler<IAgentsIndexMapper>
{
public override void RebuildIndex(ISolrOperations<IAgentsIndexMapper> indexOperations, IEnumerable<IAgentsIndexMapper> indexMapper)
{
                      ISolrOperations<IAgentsIndexMapper> indexOperationss = IOC.Container.Resolve<ISolrOperations<IAgentsIndexMapper>>();

base.RebuildIndex(indexOperationss, agentListing);
}
}
Thanks,
Kasturi Chavan

Mauricio Scheffer

unread,
Sep 28, 2015, 5:17:43 AM9/28/15
to SolrNet
Hi,

I wouldn't recommend this unless all the subclasses of IAgentsIndexMapper are mapped against the same index... which is probably not the case.

Cheers
Reply all
Reply to author
Forward
0 new messages