Hello to all, I am new in Solr, but I see it si very usable. So I whant to
build web application with asp.net MVC 4 that shows query from Solr.
Ok, let's go so far i have done this:
1) Open new project in Visual Studio 2012 and create new MVC 4 project
(Empty solution).
2) In Package Manager Console I have Install next packages:
/SolrNet (core library)
SolrNet.Windsor
SolrNet.StructureMap
SolrNet.Ninject
SolrNet.Unity
SolrNet.Autofac
SolrNet.NHibernate/
3) I create new Model class with name "Poskus" and write this code:
using SolrNet.Attributes;
/namespace TestSolr2.Models
{
public class Poskus
{
[SolrField("customer")]
public string Customer { get; set; }
}
}/
4) Next I have create new Controller with name "PoskusSolr" and write this
code:
/using System;
using System.Web.Mvc;
using SolrNet;
using SolrNet.DSL;
using TestSolr.Models;
using SolrNet.Impl;
namespace TestSolr.Controllers
{
public class PoskusSolrController : Controller
{
//
// GET: /PoskusSolr/
public ActionResult Index()
{
try
{
var connection = new
SolrConnection("http://servicemix/.../msglog_pilot";);
Startup.Init(connection);
var pos1 = Solr.Query(new SolrQueryByField("name",
"customer"));
return View(pos1);
}
catch (Exception ex)
{
string error = ex.Message;
}
return View();
}
}
}/
5) And finaly I have create View (Index)
So far I put this:
/@model TestSolr.Models.Poskus
@{
ViewBag.Title = "Index";
}
Index
/
-
Now, this code does not work, it not returns customers from my Solr databse.
Any sugestions, ideas, links to make this work. Realy, realy thanks for
help.
Daniel
--
View this message in context:
http://lucene.472066.n3.nabble.com/Asp-net-MVC-4-and-Solr-Query-Begining-tp4128372.html
Sent from the Solr - User mailing list archive at Nabble.com.