<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                [返回目錄](index.html)#### [高級應用與部署](gaoji_index.html "高級應用與部署") —— [sphinx全文索引教程](gaoji_sphinx.html "sphinx全文索引教程") Sphinx是一個基于SQL的全文檢索引擎,可以結合MySQL,PostgreSQL做全文搜索,它可以提供比數據庫本身更專業的搜索功能,使得應用程序更容易實現專業化的全文檢索。Sphinx特別為一些腳本語言設計搜索API接口,如PHP,Python,Perl,Ruby等,同時為MySQL也設計了一個存儲引擎插件。 PHPCMS V9支持這一技術,當然我們需要事先在服務器上做一些相應的部署 英文介紹:http://www.sphinxsearch.com/docs/manual-0.9.9.html ##### 一、安裝sphinx ###### 在Windows上安裝sphinx 1.下載支持mysql的包 http://www.sphinxsearch.com/downloads/sphinx-0.9.9-win32.zip 2.解壓縮 sphinx-0.9.9-win32.zip 到 D:\\sphinx 3.安裝sphinx服務,在命令行執行命令 ``` <pre class="brush:xml">D:\sphinx\searchd --install --config d:\sphinx\sphinx.conf --servicename SphinxSearch ``` 英文參照:http://www.sphinxsearch.com/docs ###### 在Linux服務器上安裝sphinx 1.下載源碼包 http://www.sphinxsearch.com/downloads/sphinx-0.9.9.tar.gz ``` <pre class="brush:xml"> $ tar xzvf sphinx-0.9.8.tar.gz $ cd sphinx $ ./configure --prefix=/usr/local/sphinx --with-mysql=/usr/local/mysql $ make $ make install ``` 問題一 ``` <pre class="brush:xml"> /usr/local/sphinx-0.9.9/src/sphinx.cpp:20060: undefined reference to `libiconv_open' /usr/local/sphinx-0.9.9/src/sphinx.cpp:20078: undefined reference to `libiconv' /usr/local/sphinx-0.9.9/src/sphinx.cpp:20084: undefined reference to `libiconv_close' collect2: ld returned 1 exit status make[2]: *** [indexer] Error 1 make[2]: Leaving directory `/home/jling/sphinx-0.9.9/src' make[1]: *** [all] Error 2 make[1]: Leaving directory `/home/jling/sphinx-0.9.9/src' make: *** [all-recursive] Error ``` 解決辦法:打開configure文件,找到“#define USE\_LIBICONV 1”,將注釋去掉,并將1改成0。 問題二 ``` <pre class="brush:xml"> error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: No such file or directory ``` 解決辦法: ``` <pre class="brush:xml"> 64位系統ln -s /usr/local/webserver/mysql/lib/mysql/libmysqlclient.so.16.0.0 /usr/lib64/libmysqlclient.so.16 32位系統ln -s /usr/local/webserver/mysql/lib/mysql/libmysqlclient.so.16.0.0 /usr/lib/libmysqlclient.so.16 ``` sphinx.conf樣例 ``` <pre class="brush:xml"> source main { type = mysql #數據庫類型 sql_host = 10.228.134.211 #數據庫ip sql_user = admin #數據庫用戶名 sql_pass = admin #數據庫密碼 sql_db = phpcms_v9 #數據庫名 sql_port = 3306 # 數據庫端口 sql_query_pre = SET NAMES utf8 sql_query_pre = REPLACE INTO v9_sphinx_counter SELECT 1, MAX(searchid) FROM v9_search sql_query = SELECT searchid, adddate, siteid, typeid, id, data FROM v9_search \ WHERE searchid>=$start AND searchid<=$end sql_query_range = SELECT 1,max_doc_id FROM v9_sphinx_counter WHERE counter_id=1 sql_range_step = 5000 #字符串屬性設置、需要過濾、排序的時候用到 sql_attr_uint = typeid sql_attr_uint = siteid sql_attr_uint = id sql_attr_timestamp = adddate sql_query_info = SELECT * FROM v9_search WHERE searchid=$id } source delta { type = mysql #數據庫類型 sql_host = 10.228.134.211 #數據庫ip sql_user = admin #數據庫用戶名 sql_pass = admin #數據庫密碼 sql_db = phpcms_v9 #數據庫名 sql_port = 3306 # 數據庫端口 sql_query_pre = SET NAMES utf8 sql_query = SELECT searchid, adddate, siteid, typeid, id, data FROM v9_search \ WHERE searchid >( SELECT max_doc_id FROM v9_sphinx_counter WHERE counter_id=1 ) sql_query_post = REPLACE INTO v9_sphinx_counter SELECT 1, MAX(searchid) FROM v9_search #字符串屬性設置、需要過濾、排序的時候用到 sql_attr_uint = typeid sql_attr_uint = siteid sql_attr_uint = id sql_attr_timestamp = adddate sql_query_info = SELECT * FROM v9_search WHERE searchid=$id } #主索引 index main { source = main # 放索引的目錄 path = D:\sphinx\data\main # 編碼 charset_type = utf-8 # 指定utf-8的編碼表 charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F # 簡單分詞,只支持0和1,如果要搜索中文,請指定為1 ngram_len = 1 # 需要分詞的字符,如果要搜索中文,去掉前面的注釋 ngram_chars = U+3000..U+2FA1F } #增量索引 index delta { source = delta path = D:\sphinx\data\delta # 編碼 charset_type = utf-8 # 指定utf-8的編碼表 charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F # 簡單分詞,只支持0和1,如果要搜索中文,請指定為1 ngram_len = 1 # 需要分詞的字符,如果要搜索中文,去掉前面的注釋 ngram_chars = U+3000..U+2FA1F } indexer { mem_limit = 128M } searchd { port = 9312 log = D:\sphinx\data\phpcms\searchd.log query_log = D:\sphinx\data\phpcms\query.log read_timeout = 5 max_children = 30 pid_file = D:\sphinx\data\phpcms\searchd.pid max_matches = 2000 seamless_rotate = 0 preopen_indexes = 0 unlink_old = 1 } ``` ##### 附件:設置計劃任務更新索引 ###### 1.windows下 需要設置計劃任務 \#凌晨4點合并索引,執行merge.bat \#其余時間每分鐘更新索引,執行delta.bat merge.bat ``` <pre class="brush:xml"> @ECHO off D:\sphinx\bin\indexer.exe --config D:\sphinx\sphinx.conf --merge main delta --rotate echo indexing, window will close when complete ``` delta.bat ``` <pre class="brush:xml"> @ECHO off D:\sphinx\bin\indexer.exe --config D:\sphinx\sphinx.conf delta --rotate echo indexing, window will close when complete ``` ###### 2.linux下編輯定時任務 crontab -e ``` <pre class="brush:xml"> #凌晨4點合并索引,其余時間每分鐘更新索引 * 0-3 * * * /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf delta --rotate * 6-23 * * * /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf delta --rotate 0 4 * * * /usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --merge main delta --rotate ``` 各種路徑、權限需要應用所在服務器一致,如: sphinx.conf 中需要配置 sql\_host 數據庫主機地址 sql\_user 數據庫用戶名 sql\_pass 數據庫密碼 sql\_db 數據庫名 sql\_port 數據庫端口 phpcms表前綴樣例中為phpcms\_ 索引路徑 D:\\sphinx\\data\\delta phpcmsv9\_withsphinx.zip [返回目錄](index.html) 上海盛大網絡發展有限公司 c 2006 - 2011 B2-20040053. 問題和建議請反饋至:http://bbs.phpcms.cn
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看