Frage

Ich bin neu in SolrNet und Asp.Net auch :) Sie schlug mich mit Antwort, HOWTO configure SolrNet für Web-Formulare.

   

 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();
        }

hier kommt meine 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; }

}

Bitte Hilfe !!!!

War es hilfreich?

Lösung

Welche Art von Fehler sehen Sie? Auch Sie zeigen nicht Ihre schema.xml (in solr / conf). Ich nehme an, es Felddefinitionen für id hat, Katze, Titel, desc, inStock und Zeitstempel?

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top