日期:2014-05-19  浏览次数:20977 次

请教一个LUCENE .NET的问题
为什么我在用SORT类进行排序时出错.
提示:field   "id "   does   not   appear   to   be   indexed
code:
_________________________________________________
IndexSearcher   seo   =   new   IndexSearcher(Application.StartupPath   +   "\\index\\ ");
Query   q   =   QueryParser.Parse(textBox1.Text, "body ",new   SimpleAnalyzer());
Lucene.Net.Search.Sort   s   =   new   Sort( "id ");
Hits   hs   =   seo.Search(q,s);
...........................
___________________________________________________
索引部分:
Document   dc   =   new   Document();
dc.Add(Field.Text( "id ",dt.Rows[i][0].ToString()));
dc.Add(Field.Text( "title ",dt.Rows[i][1].ToString()));
dc.Add(Field.Text( "body ",seg.SegmentText(dt.Rows[i][2].ToString(),true)));
iw.AddDocument(dc);


------解决方案--------------------
doc.Add(new Field( "id ", dt.Rows[i][0].ToString(), Field.Store.YES, Field.Index.UN_TOKENIZED));

是不是你的索引没建成功
------解决方案--------------------
http://www.cnblogs.com/samuel/articles/139603.html