[英]Solrnet with Web Forms
I'm new in SolrNet and Asp.Net also :) please hit me with answer, HOWTO configure SolrNet for web forms. 我也是SolrNet和Asp.Net的新手:)请回答我,如何为Web表单配置SolrNet。
public partial class CreateIndex : System.Web.UI.Page {
//http://localhost:8983/solr
private static readonly string solrURL = ConfigurationManager.AppSettings["solrUrl"];
protected void Page_Load(object sender, EventArgs e) {
var connection = new SolrConnection(solrURL);
Startup.Init<SolrProductDTO>(connection);
Entities db = new Entities();
var index = (from i in db.ItemBases.OfType<Product>()
where i.Quantity != null && i.Category != null
select new SolrProductDTO()
{
Category = i.Category.Name,
Id = i.Id,
InStock = i.IsDeleted,
Timestamp = i.CreatedDate,
Description = i.Description,
Title = i.Name
}).ToList();
var solr = ServiceLocator.Current.GetInstance<ISolrOperations<SolrProductDTO>>();
solr.Delete(SolrQuery.All);
solr.Add(index);
solr.Commit();
}
here comes my DTO: 这是我的DTO:
public class SolrProductDTO {
[SolrUniqueKey("id")]
public int Id { get; set; }
[SolrField("cat")]
public string Category { get; set; }
[SolrField("title")]
public string Title { get; set; }
[SolrField("desc")]
public string Description { get; set; }
[SolrField("inStock")]
public bool InStock { get; set; }
[SolrField("timestamp")]
public DateTime Timestamp { get; set; }
}
Please help!!!! 请帮忙!!!!
What kind of error are you seeing? 您看到哪种错误? Also, you don't show your schema.xml (in solr/conf).
另外,您不会显示您的schema.xml(在solr / conf中)。 I assume it has field definitions for id,cat,title,desc,inStock and timestamp?
我假设它具有id,cat,title,desc,inStock和timestamp的字段定义?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.