使用Hubble.Net實現全文檢索索引

來源:互聯網
上載者:User

一、下載安裝

到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);
        }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.