• 使用Hubble.Net实现全文检索


    一、 下载安装
    到Hubble.net 项目首页 http://hubbledotnet.codeplex.com/的 download tab 里面下载安装文件
    根据你的操作系统下载不同的安装包,我的系统是32位的windows 7系统,所以我下载
    最好是下载最新版的,因为新版是对旧版的改进和修复。
    Hubble。Net是个开源的项目,所以,你可以把他们的源码下载下来学习下
    还可以下载一些文档学习下,如果安装和Hubble.Net使用手册,还有Demo
    安装的时候,可以查看安装文档<<Hubble.Net安装指南.pdf>>
    二、 配置Hubble.Net 货运专家
    安装完可以在系统应用程序中看到Query Analyzer应用程序,Hubble.Net和关系数据库之间的关系,主要是通过这个工具配置的。这个查询分析器的使用方法,可以查阅文档<<查询分析器使用指南.pdf>>
    三、 需要明确几点
    1、 Hubble.Net不存在实体数据库,只是在硬盘某一目录下建一个文件夹,来存放索引文件,这个索引就类似于字典的检索目录
    2、 关系数据库和 Hubble.Net数据库要分开建,先在SQL Server Managerment Studio中建好关系数据库,然后在Query Analyzer中建数据库并建立和关系数据库的关系;Query Analyzer可以同时操作Hubble.Net数据库和关系数据库的表操作
    四、 项目中的应用
    (1)、配置webconfig文件
    <connectionStrings>
    <add name="HubbleNetConnection" connectionString="Data Source=127.0.0.1; uid=sa;pwd=123456;Initial Catalog=News;" providerName="Hubble.SQLClient"/> 女装品牌大全
    </connectionStrings>
    (2)、在Web项目中的bin中放入相应动态链接库
    (3)、连接Hubble.Net获取DataSet

    ConnectionStringSettings connString = WebConfigurationManager.ConnectionStrings["HubbleNetConnection"];
    using (HubbleConnection conn = new HubbleConnection(connString.ConnectionString))
            {
                conn.Open();

                GetColumnAnalyzerName(conn, "News");
                HubbleCommand matchCmd = new HubbleCommand(conn);

                string wordssplitbyspace;
                string titleMatchString = matchCmd.GetKeywordAnalyzerStringFromServer("News", "Title", keywords, int.MaxValue, out wordssplitbyspace);
                string contentMatchString = matchCmd.GetKeywordAnalyzerStringFromServer("News", "Content", keywords, int.MaxValue, out wordssplitbyspace);

                //查单表
                HubbleCommand cmd = new HubbleCommand("select between {0} to {1} * from News where content match {2} or title^2 match {3} order by score desc, time desc",
                    conn, (pageNo - 1) * pageLength, pageNo * pageLength - 1, contentMatchString, titleMatchString);

                //查多表(有几个需要注意的地方:1、sql前面要加[UnionSelect];2、查找的字段需写明确,不能用*;3、每个SQL返回的字段必须相同,返回的记录数也要相同;4、多条SQL之间用分号分开)
                //HubbleCommand cmd = new HubbleCommand("[UnionSelect] select between {0} to {1} title,content,url,time from News where content match {2} or title^2 match {3} order by score desc, time desc;select between {0} to {1} title,content,url,time from Activity where content match {2} or title^2 match {3} order by score desc, time desc",
                //    conn, (pageNo - 1) * pageLength, pageNo * pageLength - 1, contentMatchString, titleMatchString);

                newsDataSet = cmd.Query(CacheTimeout);
            }


  • 相关阅读:
    Json schema前奏 关于JSON
    笔试题:能被1~10同时整除的最小整数是2520,问能被1~20同时整除的最小整数是多少?
    CentOS7 安装 Docker、最佳Docker学习文档
    2019年4399暑期实习算法题2,迷宫路径条数
    2019vivo秋招提前批笔试题第3题
    python内存机制与垃圾回收、调优手段
    N皇后问题的python实现
    一行代码判断一个数是否是2的整数次方
    在O(1)的时间内删除链表节点
    打印从1到n位数的最大值
  • 原文地址:https://www.cnblogs.com/sky7034/p/2116854.html
Copyright © 2020-2023  润新知