cs代码

using System;

using System.Collections;

using System.ComponentModel;

using System.Data;

using System.Data.SqlClient;

using System.Drawing;

using System.Web;

using System.Web.SessionState;

using System.Web.UI;

using System.Web.UI.WebControls;

using System.Web.UI.HtmlControls;

using Lucene.Net;

using Lucene.Net.Index;

using Lucene.Net.Documents;

using  Lucene.Net.QueryParsers;

using Lucene.Net.Search;

using Lucene.Net.Analysis.Standard;

using Lucene.Net.Analysis.Cn;

namespace WebApplication4

...{

/**

/// WebForm1 的摘要说明。

///

public class WebForm1 : System.Web.UI.Page

...{

protected System.Web.UI.WebControls.TextBox tj;

protected System.Web.UI.WebControls.Button Search;

protected System.Web.UI.WebControls.DataGrid SearGrid;

public string connstr="server=.;database=TopWin2;uid=sa;pwd=";

private void Page_Load(object sender, System.EventArgs e)

...{

// 在此处放置用户代码以初始化页面

if (!Page.IsPostBack)

...{

//打开数据库表

SqlDataReader myred=OpenTable();

//建立索引

IndexWriter writer=CreateIndex(myred);

}

}

public SqlDataReader OpenTable()

...{

SqlConnection mycon=new SqlConnection(connstr);

mycon.Open();

SqlCommand mycom=new SqlCommand("select id,title,content from userblog order by id",mycon);

return mycom.ExecuteReader();

}

public IndexWriter CreateIndex(SqlDataReader myred)

...{

IndexWriter writer = new IndexWriter("c:/index/", new ChineseAnalyzer(), true);

try

...{

//建立索引字段

while(myred.Read())

...{

Document doc=new Document();

doc.Add(Field.Keyword("id",myred["id"].ToString()));

doc.Add(Field.Text("title",myred["title"].ToString()));

doc.Add(Field.Text("content",myred["content"].ToString()));

writer.AddDocument(doc);

}

writer.Optimize();

writer.Close();

}

catch(Exception e)

...{

Response.Write(e);

}

return writer;

}

public Hits seacher(String queryString)

...{

Hits hits=null;

try

...{

IndexSearcher mysea=new IndexSearcher("c:/index/");

Query query=QueryParser.Parse(queryString,"content",new ChineseAnalyzer());

hits=mysea.Search(query);

}

catch(Exception e)

...{

Response.Write(e);

}

return hits;

}

Web 窗体设计器生成的代码#region Web 窗体设计器生成的代码

override protected void OnInit(EventArgs e)

...{

//

// CODEGEN: 该调用是ASP.NET Web窗体设计器所必需的。

//

InitializeComponent();

base.OnInit(e);

}

/**

/// 设计器支持所需的方法-不要使用代码编辑器修改

/// 此方法的内容。

///

private void InitializeComponent()

...{

this.Search.Click += new System.EventHandler(this.Search_Click);

this.Load += new System.EventHandler(this.Page_Load);

}

#endregion

private void Search_Click(object sender, "",System.EventArgs e)

...{

DataRow myrow;

DataTable mytab=new DataTable();

mytab.Columns.Add("id");

mytab.Columns.Add("title");

mytab.Columns.Add("content");

mytab.Clear();

Hits myhit=seacher(this.tj.Text.Trim());

if (myhit!=null)

...{

for(int i=0;i

...{

Document doc=myhit.Doc(i);

myrow=mytab.NewRow();

myrow[0]=doc.Get("id").ToString();

myrow[1]=doc.Get("title").ToString();

myrow[2]=doc.Get("content").ToString();

mytab.Rows.Add(myrow);

myrow.AcceptChanges();

}

this.SearGrid.DataSource=mytab;

this.SearGrid.DataBind();

}

else

...{

//

}

}

}

}

lucene.net mysql_用Lucene[1].net对数据库建立索引及搜索+相关推荐

  1. lucene的建立索引,搜索,中文分词

    Lucene是apache软件基金会4 jakarta项目组的一个子项目,是一个开放源代码的全文检索引擎工具包. 现在最新的lucene已经更新到6.0版本了.但是这个最新版,需要适配jdk1.80以 ...

  2. LIRE(Lucene Image Retrieval)相似图像索引和搜索机制

    众说周知,lucene是一个开源的强大的索引工具,但是它仅限于文本索引.基于内容的图像检索(CBIR)要求我们利用图像的一些基本特征(如颜色纹理形状以及sift,surf等等)搜索相似的图片,LIRE ...

  3. 理解Lucene索引与搜索过程中的核心类

    理解索引过程中的核心类 执行简单索引的时候需要用的类有: IndexWriter.Directory.Analyzer.Document.Field 1.IndexWriter IndexWriter ...

  4. 建立索引lucene_用Lucene建立搜索索引

    建立索引lucene 本文是我们名为" Apache Lucene基础知识 "的学院课程的一部分. 在本课程中,您将了解Lucene. 您将了解为什么这样的库很重要,然后了解Luc ...

  5. lucene索引搜索_Lucene –快速添加索引和搜索功能

    lucene索引搜索 什么是Lucene? Apache LuceneTM是完全用Java编写的高性能,功能齐全的文本搜索引擎库. 它是一项适用于几乎所有需要全文本搜索的应用程序的技术,尤其是跨平台. ...

  6. Lucene –快速添加索引和搜索功能

    什么是Lucene? Apache LuceneTM是完全用Java编写的高性能,功能齐全的文本搜索引擎库. 它是一项适用于几乎所有需要全文搜索的应用程序的技术,尤其是跨平台的应用程序. Lucene ...

  7. java搜索引擎创建索引_搜索引擎系列 ---lucene简介 创建索引和搜索初步

    一.什么是Lucene? Lucene最初是由Doug Cutting开发的,2000年3月,发布第一个版本,是一个全文检索引擎的架构,提供了完整的查询引擎和索引引擎 :Lucene得名于Doug妻子 ...

  8. lucene索引并搜索mysql数据库[转]

    由于对lucene比较感兴趣,本人在网上找了点资料,终于成功地用lucene对mysql数据库进行索引创建并成功搜索,先总结如下: 首先介绍一个jdbc工具类,用于得到Connection对象: [j ...

  9. lucene(全文搜索)_建立索引_根据关键字全文搜索_源码下载

    项目结构: 效果图: 需要建立索引的文件(我们需要从中查找出关键字的文档) 建立好的所有文件 搜索关键字"lucene"信息 大家是不是也想亲自动手尝试一下呢... ======= ...

最新文章

  1. python培训班哪些比较好-python培训机构哪家比较好?
  2. 表达对别人的感激之情
  3. NYOJ 137 取石子(三)
  4. 图像凸性检测函数convexityDefects在Python2.7下使用opencv3.0的问题
  5. python下的scripts有什么用_python安装后无scripts内文件,无法使用pip
  6. 2021年高考英语卷三成绩查询,2021年全国3卷高考外语卷难不难,今年全国3卷高考外语卷难度系数点评...
  7. 主成份(PCA)与奇异值分解(SVD)的通俗解释
  8. 抢占云安全管理高地 启明星辰先发云SOC
  9. 【福利】10道CCNA经典测试题你能对几题?(附最新版CCNA题库下载链接)
  10. 一批信息查询网站汇总
  11. 逆向序列号生成算法(三)
  12. Batter Charger EC之间的数据交互
  13. UG NX二次开发(C#)-建模-判断一张面是孔面还是凸台面
  14. 如何将电脑文字复制到模拟器_如何将电脑中的文字复制到手机上?
  15. 【学习笔记】阿里天猫浏览型应用的CDN静态化架构演变
  16. GNN-图卷积模型-2016:GCN【消息传递(前向传播):聚合函数+更新函数】【聚合函数:mean(邻域所有节点取平均值)】【训练更新函数的参数】【空域+频域】【直推式学习】【同质图】
  17. Unity 画三角形
  18. mac 升级到山猫10.8 后导致xp 无法启动问题
  19. new URL(“www.jjj.com“)
  20. docker: Error response from daemon: Unknown runtime specified nvidia. 解决方法

热门文章

  1. CVPR2020论文解读:3D Object Detection三维目标检测
  2. CVPR2019:无人驾驶3D目标检测论文点评
  3. View的Touch事件分发(二.源码分析)
  4. 2021年大数据Hadoop(二十七):YARN运行流程
  5. 2021年大数据Spark(四十六):Structured Streaming Operations 操作
  6. python 把列表或者元组转成集合
  7. Android EditText的光标的显示与隐藏
  8. Android 使用git 忽略文件
  9. Can't create handler inside thread Thread that has not called Looper.prepare()
  10. wx.getLocation 的使用