日期:2014-05-20  浏览次数:20436 次

从lucene中检索到的结果如何与asp.net2003的DataGrid控件绑定
以下是从lucene中检索的代码:
String   Keywords=TextBox1.Text;     Keywords为查询的关键字
Hits   h   =   null;
Query   q   =   null;
IndexSearcher   s   =   new   IndexSearcher( "C:\\index ");   'index为lucene建立好的索引文件
q   =   QueryParser.Parse(Keywords, "AnchorText ",new   StandardAnalyzer());
h   =   s.Search(q);     'h为返回的结果集
if(h   !=null)
      {
if(h.Length()==0)
        Label1.Text= "No   result. ";
else
{  
                          Label1.Text= "Found   "+Keywords+ "in ";
        for(int   i=0;   i <h.Length();i++)
{
Document   doc   =   h.Doc(i);
string   f   =   doc.Get( "ID ");
                                                      Label1.Text=Label1.Text+ ", "+f;
}
}
    }
s.Close();
如何把索引的结果与asp.net2003的DataGrid控件绑定?

------解决方案--------------------
DataGrid.DataSourse =
DataGrid.DataBind();
------解决方案--------------------
Hits h = null;
看看这个hits是什么样的数据结构?
另外全文检索的结果集可能很大,不可能一次性绑定datagrid,可以考虑用google似的通过页面回发来分部载入.
------解决方案--------------------
http://www.qiyesucha.com