Dave Burke : Freelance .NET Web Developer specializing in Online Communities

Searching multiple fields in dotText with Lucene


Lucene.NET kicks butt.  I LUV IT!  Truly.  Boolean, exact phrase, wildcard, can use in combination, and fast!  I was so glad I decided to use those pieces from ScottW's splendid 0.96 source (or whatever its designation.)

So I'm groovin' on this beefy blog searching when I discover that only my blog body content is being searched.  The titles weren't included in the search.  The Librarian in me was aghast.

There had to be a way to include the title in the search.  The wise coders behind the Lucene engine had to have included that capability, but where?

I found the answer in the DotText.Search.EntryData.cs class and the CreateDoc method where the index documents are formed.  The RawPost field had to be modified to include any additional fields.  It was here that I added the post Title field from the datareader, and for a community blog environment, added author as well.  It would have been nice to add categories, but that would have been messier.  I'd like to add that capability, too, and perhaps concatenating them in the SQL blog_aggregate_search proc, return them in the reader and append to the RawPost field.  Yeah, that would probably work. 

The original line of code is commented out with the multi-field version listed afterward.

              //doc.Add(Field.Text(SearchConfiguration.RawPost,regexStripHTML.Replace(body,string.Empty)));
               doc.Add(Field.Text(SearchConfiguration.RawPost,regexStripHTML.Replace(body,string.Empty) + " |  Post Title: " + title));


Comments (0) | Post RSS RSS comment feed

Posted on 2/15/2005 12:54:00 AM by Dave Burke
Categories:
Tags: no tags for this post

Related posts


Powered by BlogEngine.NET 2.0.0.36
Theme by Dave Burke