Login

Username

Password





Register   Reset password

This is a read-only archive of the forum.

# mgaerber 8/17/2005 10:36 AM

On a previous thread Martijn talked about making the Search Category-aware.

I've looked a little bit deeper into the workings of dotLucene and am wondering how this could be achieved if your content belongs to different categories.

I know that one can add fields to Lucene index documents but if one content item fits into many categories, how would your search be performed?
Adding a delimiter separated string of category identifiers to the field in the index and then?

Since being a full-text index, having category ids, let's say 112 and 113, in the index field would also give an answer when searching for items related to a category with id 11, right?

Does anybody have a good solution for this?

# martijnb 8/17/2005 1:29 PM
With DotLucene it is very easy. Everything is a Document object and in the code you add Fields to a Document that function as meta-data. Now the nice thing is, you can add several fields that have the same name, so when content is in three categories, you add three fields to the Document, one for each category:
Document doc = new Document();
doc.Add(Field.Text("title", "The title"));
doc.Add(Field.Text("summary", "Yada yada"));
doc.Add(Field.UnStored("contents", "More yada yada"));
doc.Add(Field.Text("author", "The author"));
doc.Add(Field.Keyword("category", "Category 1"));
doc.Add(Field.Keyword("category", "Category 2"));
doc.Add(Field.Keyword("category", "Category 3"));

Currently Cuyahoga uses the SearchContent class (used with the ISearchable interface) to 'feed' DotLucene with content. This class has one Category property, but that can easily be changed into a list of categories.