solr.net实践(二)

Setting up the library

Once you have created your document class, you have to initialize the library in order to operate against the Solr instance. This is usually done once at application startup:(通常在程序开始时,启动一次即可 例如:application.start)
Startup
.Init<Product>("http://localhost:8983/solr");

Then you ask the service locator for the SolrNet service instance which allows you to issue any supported operation:

var solr =ServiceLocator.Current.GetInstance<ISolrOperations<Product>>();
solr.Delete(SolrQuery.All);
solr.Add(p);
solr.Commit();
var products = solr.Query(newSolrQueryByRange<decimal>("price",10m,100m));

 




posted on 2012-02-14 11:25  雨渐渐  阅读(382)  评论(0编辑  收藏  举报

导航