views:

67

answers:

1

Hi people,

I'm new in SolrNet and Asp.Net also :) please hit me with answer, HOWTO configure SolrNet for web forms.

400 http error

 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:

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!!!!

+1  A: 

What kind of error are you seeing? Also, you don't show your schema.xml (in solr/conf). I assume it has field definitions for id,cat,title,desc,inStock and timestamp?

Ken Foster
I'm using LucidWorks => Solr under Apache Tomcat.I didn't change schema, I thought schema will be changed when I invoke init.Anyway, should I manually write my Dto's fields to schema?
omoto