zoukankan      html  css  js  c++  java
  • 使用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);
            }


  • 相关阅读:
    一个很实用的css3兼容工具很多属性可以兼容到IE6
    html5 canvas 填充渐变形状
    找到任何形状的中心-总结篇
    html canvas非正方旋转和缩放...写的大多是正方的有人表示一直看正方的看厌了
    把jQuery的类、插件封装成seajs的模块的方法
    那些年实用但被我忘掉javascript属性.onresize
    总有一些实用javascript的元素被人遗忘在角落-slice
    jquery(入门篇)无缝滚动
    html5 canvas旋转+缩放
    今天看到这篇新闻之后,决定休息一下咯
  • 原文地址:https://www.cnblogs.com/sky7034/p/2116854.html
Copyright © 2011-2022 走看看