0

I'm trying to add a search field to my web site (ASP.NET MVC 2) and was told it'd be a good idea to use Nhibernate.Search, seeing that I was already using Nhibernate in the rest of the project.

Anyway, I followed a coulpe tutorials, namely this one, and some questions and answeres on this site, but in the end, it does not build an index, and searches come empty.

I know this question might be a bit vague, but it seems strange that nothing works even after I've done everything I was told.

Well, almost everything. At some point, in one of the tutorials, it tells me to type:

using (IFullTextSession s = Search.CreateFullTextSession(sf.OpenSession(new SearchInterceptor()))) {

        QueryParser qp = new QueryParser("id", new StopAnalyzer());

        IQuery NHQuery = s.CreateFullTextQuery(qp.Parse("Summary:series"), typeof(Book));

        IList result = NHQuery.List();

        Debug.Assert(result.Count == 2);
}

wich does not work because SearchInterceptor does not exist anywhere...

Am I missing something here? Is there a way to better write the search queries? In which part of my application does it build the index?

Thanks in advance.

JLago
  • 31
  • 3

1 Answers1

0

I've tried something like:

public bool LuceneIndexAllVideos()
    {
        var s = NHibernate.Search.Search.CreateFullTextSession(Session);

        foreach (Video video in Videos)
        {
            s.Index(video);
        }
        return true;
    }

But is slow, but it seems to work nice... See: https://stackoverflow.com/questions/6989125/lucene-net-nhibernate-updating-lucene-index-from-existing-data

Community
  • 1
  • 1
Rui Lima
  • 7,185
  • 4
  • 31
  • 42