<iframe marginwidth="0" marginheight="0" src="http://218.16.120.35:65001/PC/Global/images/b.html" frameborder="0" width="728" scrolling="no" height="90"></iframe>
private void BuildIndex_Category(int index, int len)
{
try
{
DB = new DBConnect(textBox1.Text.Trim());
string sql = "select * from common_category where COMMON_CATEGORY_ID> " + index.ToString() + " and COMMON_CATEGORY_ID <= " + Convert.ToString(index + len) + " order by COMMON_CATEGORY_ID ";
DataSet ds = DB.ExecuteQuery(sql);
bool IsCreate = true;
if (Directory.Exists("CategoryIndex"))
{
IsCreate = false;
}
IndexWriter writer = new IndexWriter("CategoryIndex", new StandardAnalyzer(), IsCreate);//判断是否递增
string[] cols = { "COMMON_CATEGORY_ID","COMMON_CATEGORY_NAME"};
foreach (DataRow r in ds.Tables[0].Rows)
{
Document doc = new Document();
doc.Add(Field.Keyword("COMMON_CATEGORY_ID", r["COMMON_CATEGORY_ID"].ToString()));
doc.Add(Field.Text("COMMON_CATEGORY_NAME", r["COMMON_CATEGORY_NAME"].ToString()));
writer.AddDocument(doc);
}
writer.Optimize();
writer.Close();
int current = index + len;
Tool.NewSaveToFile("category.inx", current.ToString());
}
catch (Exception ex)
{
MessageBox.Show("数据库连接失败!");
}
//string t2 = DateTime.Now.ToString();
// MessageBox.Show(t1 + "=====" + t2);
}
private ArrayList Search(string IndexPath, string key)
{
IndexSearcher indexSearcher = new IndexSearcher(IndexPath);
Query query = QueryParser.Parse(key, "contents", new StandardAnalyzer());
Hits hits = indexSearcher.Search(query);
//存储
ArrayList list = new ArrayList();
for (int i = 0; i < hits.Length(); i++)
{
Document doc = hits.Doc(i);
string strID = doc.Get("filename");
list.Add(strID);
}
indexSearcher.Close();
return list;
}
分享到:
相关推荐
基于lucene 2.4简单的一个索引和搜索实例
在Eclipse环境中运用java,Lucene建索引及查询关键字
C#调用Lucene方法-实现快速搜索
Lucene创建索引步骤: 1、创建Directory(索引位置) 2、创建IndexWrite(写入索引) 3、创建Document对象 4、为Document添加Field(相当于添加属性:类似于表与字段的关系) 5、通过IndexWriter添加文档到索引中
基于lucene的索引与搜索 基于lucene的索引与搜索
lucene3.0.3搜索的使用示例lucene3.0.3搜索的使用示例lucene3.0.3搜索的使用示例
Lucene创建索引,查询索引的简单使用。
Lucene3.0创建索引 读取目录下的所有txt文档格式的文件,然后生成一个索引文件到某目录下!
Lucene实现索引和查询的实例讲解Lucene实现索引和查询的实例讲解
一个开源的lucene索引查看程序及代码,
C#+Lucene.Net开发完成的一个自定义WEB搜索引擎,本项目实现了分词、模糊索引,加以Lucene.Net内部核心功能共同实现了搜索机制引擎
Lucene5写的全文搜索的demo,包括创建索引和搜索
主要将如何使用Lucene建立索引以及搜索进行了代码的实现,有利于初学者熟悉Lucene的基本功能。
Examine 允许您轻松地索引和搜索数据,并封装了 Lucene.Net 索引/搜索引擎。Lucene速度非常快,即使在非常大量的数据上也可以进行非常快速的搜索。检查是非常可扩展的,允许您配置任意数量的索引,并且每个索引都...
lucene3.0庖丁+索引搜索程序,里面有代码示例
Lucene索引器实例Lucene索引器实例Lucene索引器实例Lucene索引器实例
java创建Lucene索引
lucene索引结构原理
lucene 做索引查询流程,来自《lucene in action》
iTextPDFExtractor.java ------ ...--PDFBox创建PDF文件的Lucene索引 PDFBoxPathIndex.java ------- --PDFBox创建指定目录PDF文档索引 POIOfficeExtractor.java ----- -- POI处理Excel和Word文档代码