Weaving dream dedecms v5.7 Full Text Search instruction (Sphinx)

Source: Internet
Author: User
Tags manual joins win32

Official website: http://www.sphinxsearch.com/
Official Document: http://www.sphinxsearch.com/docs/
Chinese support: http://www.coreseek.cn/
Download the Chinese user manual: Http://www.coreseek.cn/uploads/pdf/sphinx_doc_zhcn_0.9.pdf
Online Manual for Chinese: http://www.coreseek.cn/docs/coreseek_3.2-sphinx_0.9.9.html

1.Windows under Installation Sphinx
1.1. Preparatory work before the start

Download Coreseek 3.2.13 from http://www.coreseek.cn/products/ft_down/First, and here we take the Windows environment as an example:
After downloading the direct decompression Coreseek-3.2.13-win32.zip, we here assume decompression to: D:\coreseek-3.2.13-win32. Here we need to know a few simple directories:

[D:\coreseek-3.2.13-win32\api] API interface directory, which includes Php,python,ruby and other operational examples, of which test_coreseek.php is a good example of Chinese retrieval.

The [D:\****\bin] application directory, which contains several files
* Indexer: Used to create full-text indexing;
* Search: A simple command line (CLI) test procedure for testing full-text indexing;
* Searchd: A daemon, other software can be through this daemon for full-text retrieval;
* Sphinxapi: A series of SEARCHD client API libraries for popular web scripting development languages (PHP, Python, Perl, Ruby, Java).
* Spelldump: A simple command-line tool for extracting entries from a dictionary in Ispell or MySpell (OpenOffice built-in bindings) format. These entries can be used to customize the index when using Wordforms.
* Indextool: Tool program for dumping multiple debug information about an index. This tool was added starting from version Coreseek 3.1 (Sphinx 0.9.9-rc2).
* MMSEG: Tools and libraries, coreseek to provide Chinese word segmentation and dictionary processing.

[D:\****\etc]sphinx Configuration directory
[D:\****\var]sphinx Variables & index & log storage directory

1.2. Create a configuration file
Since Dedecms is using MySQL, we need to configure a MySQL Sphinx template configuration that can replicate csft_mysql.conf renamed to: csft_dedecmsv57.conf, for example, we only make a fuss of full-text search here, We need to make the following configuration:
Create a table in Dedecms to execute the following code in the DEDECMS background [System]->[sql command-line tool]:
CREATE TABLE ' Dede_sphinx ' (
' Countid ' int (one) unsigned not NULL,
' Maxaid ' int (one) unsigned not NULL,
PRIMARY KEY (' Countid ')
) Engine=myisam DEFAULT CHARSET=GBK
This is a Sphinx content table that is used to generate indexes in batches for a large amount of data.
After the data table is created, we modify the Sphinx configuration file, the csft_dedecmsv57.conf, with the following comments:
--------------------------------------------------------------------------------------------

#源定义
SOURCE MySQL
{
Type = MySQL

# Database Server Basic configuration information
Sql_host = 192.168.0.103
Sql_user = dedev57
Sql_pass = Dedecms
sql_db = DEDECMSV57GBK
Sql_port = 3306

# set code, here we are GBK encoded, if it is utf-8, can be set:
# sql_query_pre = SET NAMES UTF8
Sql_query_pre = SET NAMES GBK

# Data Retrieval Increment
Sql_range_step = 1000

#当前最新文档id数
Sql_query_pre = REPLACE into Dede_sphinx SELECT 1, MAX (ID) from dede_archives

#检索条件
Sql_query = SELECT Arc.id,arc.typeid,arc.typeid2,arc.sortrank,arc.flag,arc.channel,arc.ismake,arc.arcrank,ar C.click,arc.title,arc.shorttitle,arc.color,arc.writer,arc.source,arc.litpic,arc.pubdate,arc.senddate,arc.mtype , Arc.description,arc.badpost,arc.goodpost,arc.scores,arc.lastpost,arc.keywords,arc.mid,art.body from Dede_ Archives as ARC left joins Dede_addonarticle as ART on arc.id = Art.aid WHERE arc.id>= $start and arc.id<= $end #sql_qu ery first column ID must be an integer
#title, body as a string/text field, indexed by the full text

# Gets the current maximum search ID
Sql_query_range = SELECT 1,maxaid from Dede_sphinx WHERE countid=1


Sql_attr_uint = typeID #从SQL读取到的值必须为整数
Sql_attr_uint = Typeid2
Sql_attr_uint = Channel
Sql_attr_uint = Click
Sql_attr_uint = Badpost
Sql_attr_uint = Goodpost
Sql_attr_uint = Scores
Sql_attr_uint = mid
Sql_attr_timestamp = pubdate #从SQL读取到的值必须为整数, as a time attribute
Sql_attr_timestamp = Senddate
Sql_attr_timestamp = Lastpost

#命令行查询时 to read raw data information from the database
Sql_query_info = SELECT arc.*,art.body from dede_archives as ARC left joins Dede_addonarticle as ART on arc.id = Art.aid WHERE arc.id= $id
}

Source Delta
{
    type                     = MySQL

# Database Server Basic configuration information
Sql_host = 192.168.0.103
Sql_user = dedev57
Sql_pass = Dedecms
sql_db = DEDECMSV57GBK
Sql_port = 3306
Sql_query_pre = SET NAMES GBK

# Incremental index, starting with the maximum ID
Sql_query = SELECT Arc.id,arc.typeid,arc.typeid2,arc.sortrank,arc.flag,arc.channel,arc.ismake,arc.arcrank, Arc.click,arc.title,arc.shorttitle,arc.color,arc.writer,arc.source,arc.litpic,arc.pubdate,arc.senddate, Arc.mtype,arc.description,arc.badpost,arc.goodpost,arc.scores,arc.lastpost,arc.keywords,arc.mid,art.body from Dede_archives as ARC left joins Dede_addonarticle as ART on arc.id = Art.aid WHERE arc.id > (SELECT maxaid from dede_sp Hinx WHERE countid=1)
#从SQL读取到的值必须为整数

Sql_query_post = REPLACE into Dede_sphinx SELECT 1, MAX (ID) from dede_archives

Sql_attr_uint = typeID
Sql_attr_uint = Typeid2
Sql_attr_uint = Channel
Sql_attr_uint = Click
Sql_attr_uint = Badpost
Sql_attr_uint = Goodpost
Sql_attr_uint = Scores
Sql_attr_uint = mid
Sql_attr_timestamp = pubdate #从SQL读取到的值必须为整数, as a time attribute
Sql_attr_timestamp = Senddate
Sql_attr_timestamp = Lastpost

#命令行查询时 to read raw data information from the database
Sql_query_info = SELECT arc.*,art.body from dede_archives as ARC left joins Dede_addonarticle as ART on arc.id = Art.aid WHERE arc.id= $id
}

#index定义
Index MySQL
{
Source = MySQL #对应的source名称
Path = D:/coreseek-3.2.13-win32/var/data/mysql
DocInfo = extern
Mlock = 0
Morphology = None
Min_word_len = 1
Html_strip = 0
#charset_dictpath =/usr/local/mmseg3/etc/#BSD, settings under Linux,/end of symbol
Charset_dictpath = d:/coreseek-3.2.13-win32/etc/#Windows环境下设置,/end of symbol
Charset_type = ZH_CN.GBK
}

Index Delta:mysql
{
Min_word_len = 1
Source = Delta
Path = D:/coreseek-3.2.13-win32/var/data/delta.new
}

#全局index定义
Indexer
{
Mem_limit = 128M
}

#searchd服务定义
Searchd
{
    listen                   =   9312
    read_timeout         = 5
    max_children        =
    max_matches            =
    seamless_rotate        = 0
    preopen_indexes        = 0
    unlink_old            = 1
    pid_file = d:/coreseek-3.2.13-win32/var/log/searchd_mysql.pid
    log = D:/coreseek-3.2.13-win32/var/log/searchd_mysql.log
    query_log = d:/ Coreseek-3.2.13-win32/var/log/query_mysql.log
}

-------------------------------------------------------------------------------------------------------

1.3. Building an index
After the configuration is complete, we will set up the index, open [run] in the Start menu, enter "cmd", and open the command line after confirmation. Enter the following code:

D:&CD D:\coreseek-3.2.13-win32\bin

First, switch to the bin directory of Sphinx and then execute:

Indexer.exe-c D:\coreseek-3.2.13-win32\etc\csft_dedecmsv57.conf MySQL--rotate

This time Sphinx start building the index, and if the amount of data is large, this may be longer, and you need to wait patiently (Figure 1).



Javashop Mall System, Professional _ Worry "click into" Multi-user mall system, distribution system, CMS system High-quality professional Mall system service Provider View

Then create the next incremental index, using the following command:
Indexer.exe-c D:\coreseek-3.2.13-win32\etc\csft_dedecmsv57.conf Delta--rotate

1.4. Test whether the search is normal
After the index has been established, we will detect if the match can be found properly, and you can continue to enter the following command in CMD:

Search.exe-c D:\coreseek-3.2.13-win32\etc\csft_dedecmsv57.conf Dedecms

If the data can be returned normally (Figure 2), the index has been successfully established.



Javashop Mall System, Professional _ Worry "click into" Multi-user mall system, distribution system, CMS system High-quality professional mall system service provider

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.