I am using Lucene.Net 3.0.3. I'm trying to sort my result by product price and stock. But the sorting doesn't seem to be doing anything. I tried debugging the lucene searcher.Search() in Visual Studio, but this will eventually throw a debug exception: http://i62.tinypic.com/m7zyi9.png
My code looks like this:
Adding the fields to the document:
doc.Add(new NumericField("Price", Field.Store.YES, true).SetFloatValue(productLucene.Price));
doc.Add(new NumericField("Stock", Field.Store.YES, true).SetIntValue(productLucene.Stock));
Creating the sort:
switch (sortField)
{
case "Price":
sortFieldType = SortField.FLOAT;
break;
case "Stock":
sortFieldType = SortField.INT;
break;
}
sort = new Sort(new SortField(sortField, sortFieldType, false));
Sort the result set:
var hits = searcher.Search(booleanQuery, null, _hitsLimit, sort).ScoreDocs;
var results = _mapLuceneToDataList(hits, searcher);
I also tried sorting by string and String_val, but this doesn't make any difference. I know the fields should be indexed to be able to sort. I know the field should be untokenized, but I can't find the untokenized index option in lucene.net 3.0.3. Any help would be appreciated.