---
title: "sphinx(或coreseek)配置文件记录"
author: "phpseyo"
date: "2012-08-29T09:51:26Z"
tags: []
categories: ["开源软件"]
slug: "sphinx-coreseek"
draft: false
lastmod: "2012-08-29T09:51:26Z"
id: 1666280
url: "https://phpseyo.iteye.com/blog/1666280"
---

\#

\# Sphinx configuration file sample

\#

\# WARNING! While this sample file mentions all available options,

\# it contains (very) short helper descriptions only. Please refer to

\# doc/sphinx.html for details.

\#

 

#############################################################################

\## data source definition

#############################################################################

 

source src1

{

    # data source type. mandatory, no default value

    # known types are mysql, pgsql, mssql, xmlpipe, xmlpipe2, odbc

    type            = mysql

 

    #####################################################################

    ## SQL settings (for 'mysql' and 'pgsql' types)

    #####################################################################

 

    # some straightforward parameters for SQL source types

    sql\_host        = localhost

    sql\_user        = root

    sql\_pass        = \*\*\*\*\** 

    sql\_db            = \*\*\*\*\**

    sql\_port        = 3306    # optional, default is 3306

 

    # UNIX socket name

    # optional, default is empty (reuse client library defaults)

    # usually '/var/lib/mysql/mysql.sock' on Linux

    # usually '/tmp/mysql.sock' on FreeBSD

    #

    sql\_sock        = /tmp/mysql.sock

 

 

    # MySQL specific client connection flags

    # optional, default is 0

    # 数据传输方式

    # mysql\_connect\_flags    = 32 # enable compression

 

    # MySQL specific SSL certificate settings

    # optional, defaults are empty

    # SLL链接

    # mysql\_ssl\_cert        = /etc/ssl/client-cert.pem

    # mysql\_ssl\_key        = /etc/ssl/client-key.pem

    # mysql\_ssl\_ca        = /etc/ssl/cacert.pem

 

    # MS SQL specific Windows authentication mode flag

    # MUST be in sync with charset\_type index-level setting

    # optional, default is 0

    #

    # mssql\_winauth        = 1 # use currently logged on user credentials

 

 

    # MS SQL specific Unicode indexing flag

    # optional, default is 0 (request SBCS data)

    #

    # mssql\_unicode        = 1 # request Unicode data from server

 

 

    # ODBC specific DSN (data source name)

    # mandatory for odbc source type, no default value

    #

    # odbc\_dsn        = DBQ=C:\\data;DefaultDir=C:\\data;Driver={Microsoft Text Driver (\*.txt; \*.csv)};

    # sql\_query        = SELECT id, data FROM documents.csv

 

 

    # ODBC and MS SQL specific, per-column buffer sizes

    # optional, default is auto-detect

    #

    # sql\_column\_buffers    = content=12M, comments=1M

 

 

    # pre-query, executed before the main fetch query

    # multi-value, optional, default is empty list of queries

    # 发送SQL语句前发送

    sql\_query\_pre        = SET NAMES utf8

    sql\_query\_pre        = SET SESSION query\_cache\_type=OFF

 

 

    # main document fetch query

    # mandatory, integer document ID field MUST be the first selected column

    # 需要查询的表 构建查询

    sql\_query        = \\

        SELECT id,target\_type,genre,stars,sub\_title,sports\_team,music\_band,music\_album \\

        FROM ko\_link

    #如果多个数据源并要在一个索引,必须要保持字段的顺序数量跟数据都要一致,否则将出错

 

 

    # joined/payload field fetch query

    # joined fields let you avoid (slow) JOIN and GROUP\_CONCAT

    # payload fields let you attach custom per-keyword values (eg. for ranking)

    #

    # syntax is FIELD-NAME 'from'  ( 'query' | 'payload-query' ); QUERY

    # joined field QUERY should return 2 columns (docid, text)

    # payload field QUERY should return 3 columns (docid, keyword, weight)

    #

    # REQUIRES that query results are in ascending docuent ID order!

    # multi-value, optional, default is empty list of queries

    #  添加字段,来源与表 自动连接

    # 字段结果集保持为

    # (1,tags1)

    # (1,tags2)

    # (2,tags3)

    # (2,tags4)

    # 添加字段将用于搜索,结果如有第3个字段,第3个字段表示该记录的权重,权重为大于1的值

    # sql\_joined\_field    = tags from query; SELECT docid, CONCAT('tag',tagid) FROM tags ORDER BY docid ASC

    # sql\_joined\_field    = wtags from payload-query; SELECT docid, tag, tagweight FROM tags ORDER BY docid ASC

 

 

    # file based field declaration

    #

    # content of this field is treated as a file name

    # and the file gets loaded and indexed in place of a field

    #

    # max file size is limited by max\_file\_field\_buffer indexer setting

    # file IO errors are non-fatal and get reported as warnings

    # 把字段声明放入文件

    # sql\_file\_field        = content\_file\_path

 

 

    # range query setup, query that must return min and max ID values

    # optional, default is empty

    # 

    # sql\_query will need to reference $start and $end boundaries

    # if using ranged query:

    # 分区查询,防止MYSQL死锁

    # sql\_query        = \\

    #    SELECT doc.id, doc.id AS group, doc.title, doc.data \\

    #    FROM documents doc \\

    #    WHERE id&gt;=$start AND id&lt;=$end

    #

    # sql\_query\_range        = SELECT MIN(id),MAX(id) FROM documents

 

 

    # range query step

    # optional, default is 1024

    # 分区查询跳步

    # sql\_range\_step        = 1000

 

 

 

 

    # unsigned integer attribute declaration

    # multi-value (an arbitrary number of attributes is allowed), optional

    # optional bit size can be specified, default is 32

    # 声明无符号数字段

    #sql\_attr\_uint        = target\_type

    # sql\_attr\_uint        = forum\_id:9 # 9 bits for forum\_id

    #sql\_attr\_uint        = group\_id

    #声明BOOL字段

    # boolean attribute declaration

    # multi-value (an arbitrary number of attributes is allowed), optional

    # equivalent to sql\_attr\_uint with 1-bit size

    #

    # sql\_attr\_bool        = is\_deleted

 

 

    # bigint attribute declaration

    # multi-value (an arbitrary number of attributes is allowed), optional

    # declares a signed (unlike uint!) 64-bit attribute

    # 声明长整字段

    # sql\_attr\_bigint        = my\_bigint\_id

 

 

    # UNIX timestamp attribute declaration

    # multi-value (an arbitrary number of attributes is allowed), optional

    # similar to integer, but can also be used in date functions

    # 声明时间字段

    # sql\_attr\_timestamp    = posted\_ts

    # sql\_attr\_timestamp    = last\_edited\_ts

    #sql\_attr\_timestamp    = date\_added

 

    # string ordinal attribute declaration

    # multi-value (an arbitrary number of attributes is allowed), optional

    # sorts strings (bytewise), and stores their indexes in the sorted list

    # sorting by this attr is equivalent to sorting by the original strings

    # 声明字符串字段 用于排序等,但此字段不会被存储

    # sql\_attr\_str2ordinal    = author\_name

 

 

    # floating point attribute declaration

    # multi-value (an arbitrary number of attributes is allowed), optional

    # values are stored in single precision, 32-bit IEEE 754 format

    # 声明浮点字段

    # sql\_attr\_float        = lat\_radians

    # sql\_attr\_float        = long\_radians

 

 

    # multi-valued attribute (MVA) attribute declaration

    # multi-value (an arbitrary number of attributes is allowed), optional

    # MVA values are variable length lists of unsigned 32-bit integers

    #

    # syntax is ATTR-TYPE ATTR-NAME 'from' SOURCE-TYPE \[;QUERY] \[;RANGE-QUERY]

    # ATTR-TYPE is 'uint' or 'timestamp'

    # SOURCE-TYPE is 'field', 'query', or 'ranged-query'

    # QUERY is SQL query used to fetch all ( docid, attrvalue ) pairs

    # RANGE-QUERY is SQL query used to fetch min and max ID values, similar to 'sql\_query\_range'

    # 声明复合字段

    # sql\_attr\_multi        = uint tag from query; SELECT docid, tagid FROM tags

    # sql\_attr\_multi        = uint tag from ranged-query; \\

    #    SELECT docid, tagid FROM tags WHERE id&gt;=$start AND id&lt;=$end; \\

    #    SELECT MIN(docid), MAX(docid) FROM tags

 

 

    # string attribute declaration

    # multi-value (an arbitrary number of these is allowed), optional

    # lets you store and retrieve strings

    # 只是把数据存储,但不会索引改字段

    # sql\_attr\_string        = stitle

 

 

    # wordcount attribute declaration

    # multi-value (an arbitrary number of these is allowed), optional

    # lets you count the words at indexing time

    # 将转化成关键字的字段,用于提高匹配率

    # sql\_attr\_str2wordcount    = stitle

 

 

    # combined field plus attribute declaration (from a single column)

    # stores column as an attribute, but also indexes it as a full-text field

    # 跟sql\_attr\_string不同是该属性加入索引

    # sql\_field\_string    = author

    # sql\_field\_str2wordcount    = title

 

 

    # post-query, executed on sql\_query completion

    # optional, default is empty

    # 取后查询

    # sql\_query\_post        =

 

 

    # post-index-query, executed on successful indexing completion

    # optional, default is empty

    # $maxid expands to max document ID actually fetched from DB

    # 索引后查询

    # sql\_query\_post\_index    = REPLACE INTO counters ( id, val ) \\

    #    VALUES ( 'max\_indexed\_id', $maxid )

 

 

    # ranged query throttling, in milliseconds

    # optional, default is 0 which means no delay

    # enforces given delay before each query step

    #分区查询的时间间隔

    sql\_ranged\_throttle    = 0

 

    # document info query, ONLY for CLI search (ie. testing and debugging)

    # optional, default is empty

    # must contain $id macro and must fetch the document by that id

    #命令行调试查询结果用

    sql\_query\_info        = SELECT * FROM ko\_link WHERE id=$id

 

    # kill-list query, fetches the document IDs for kill-list

    # k-list will suppress matches from preceding indexes in the same query

    # optional, default is empty

    ##清理指定查询ID列表,对于数据的更改

    # sql\_query\_killlist    = SELECT id FROM documents WHERE edited&gt;=@last\_reindex

 

 

    # columns to unpack on indexer side when indexing

    # multi-value, optional, default is empty list

    # 启用ZIP压缩 可以降低系统负载 但必须保证zlib库zlib-dev库可用

    # unpack\_zlib        = zlib\_column

    # unpack\_mysqlcompress    = compressed\_column

    # unpack\_mysqlcompress    = compressed\_column\_2

 

 

    # maximum unpacked length allowed in MySQL COMPRESS() unpacker

    # optional, default is 16M

    # 压缩缓存区大小 不能小于字段存储值

    # unpack\_mysqlcompress\_maxsize    = 16M

 

 

    #####################################################################

    ## xmlpipe2 配置

    #####################################################################

 

    # type            = xmlpipe

 

    # shell command to invoke xmlpipe stream producer

    # mandatory

    #

    # xmlpipe\_command        = cat /usr/local/sphinx/var/test.xml

 

    # xmlpipe2 field declaration

    # multi-value, optional, default is empty

    #

    # xmlpipe\_field        = subject

    # xmlpipe\_field        = content

 

 

    # xmlpipe2 attribute declaration

    # multi-value, optional, default is empty

    # all xmlpipe\_attr\_XXX options are fully similar to sql\_attr\_XXX

    #

    # xmlpipe\_attr\_timestamp    = published

    # xmlpipe\_attr\_uint    = author\_id

 

 

    # perform UTF-8 validation, and filter out incorrect codes

    # avoids XML parser choking on non-UTF-8 documents

    # optional, default is 0

    #

    # xmlpipe\_fixup\_utf8    = 1

}

 

 

\# inherited source example

\# 继承数据源

\# all the parameters are copied from the parent source,

\# and may then be overridden in this source definition

#source src1throttled : src1

#{

\#    sql\_ranged\_throttle    = 100

#}

 

#############################################################################

\## index definition

#############################################################################

 

\# local index example

\#

\# this is an index which is stored locally in the filesystem

\#

\# all indexing-time options (such as morphology and charsets)

\# are configured per local index

index test1

{

    # index type

    # optional, default is 'plain'

    # known values are 'plain', 'distributed', and 'rt' (see samples below) 

    #索引类型 本地 分布式 

    # type            = plain

 

    # document source(s) to index

    # multi-value, mandatory

    # document IDs must be globally unique across all sources

    #数据源,可以多个数据源

    source            = src1

 

    # index files path and file name, without extension

    # mandatory, path must be writable, extensions will be auto-appended

    # 索引保存路径

    path            = /usr/local/sphinx/var/data/test1

 

    # document attribute values (docinfo) storage mode

    # optional, default is 'extern'

    # known values are 'none', 'extern' and 'inline'

    #索引存储方式

    docinfo            = extern

 

    # memory locking for cached data (.spa and .spi), to prevent swapping

    # optional, default is 0 (do not mlock)

    # requires searchd to be run from root

    #内存锁定 需要保证足够权限

    mlock            = 0

 

    # a list of morphology preprocessors to apply

    # optional, default is empty

    #

    # builtin preprocessors are 'none', 'stem\_en', 'stem\_ru', 'stem\_enru',

    # 'soundex', and 'metaphone'; additional preprocessors available from

    # libstemmer are 'libstemmer\_XXX', where XXX is algorithm code

    # (see libstemmer\_c/libstemmer/modules.txt)

    # 词语提取器

    # morphology        = stem\_en, stem\_ru, soundex

    # morphology        = libstemmer\_german

    # morphology        = libstemmer\_sv

    morphology        = stem\_en

 

    # minimum word length at which to enable stemming

    # optional, default is 1 (stem everything)

    # 词干化的最小词长

    # min\_stemming\_len    = 1

 

 

    # stopword files list (space separated)

    # optional, default is empty

    # contents are plain text, charset\_table and stemming are both applied

    # 停用搜索词

    # stopwords        = /usr/local/sphinx/var/data/stopwords.txt

 

 

    # wordforms file, in "mapfrom &gt; mapto" plain text format

    # optional, default is empty

    # 词型字典 可用spelldump工具生成

    # wordforms        = /usr/local/sphinx/var/data/wordforms.txt

 

 

    # tokenizing exceptions file

    # optional, default is empty

    #Token特例文件,就是有些词是完整词意,不能拆分索引如a&t 跟a & t

    # plain text, case sensitive, space insensitive in map-from part

    # one "Map Several Words =&gt; ToASingleOne" entry per line

    #

    # exceptions        = /usr/local/sphinx/var/data/exceptions.txt

 

 

    # minimum indexed word length

    # default is 1 (index everything)

    #  最小索引长度,就是小于指定长度的词不被索引

    min\_word\_len        = 1

 

    # charset encoding type

    # optional, default is 'sbcs'

    # known types are 'sbcs' (Single Byte CharSet) and 'utf-8'

    # 字符编码

    charset\_type        = utf-8

 

    # charset definition and case folding rules "table"

    # optional, default value depends on charset\_type

    #

    # defaults are configured to include English and Russian characters only

    # you need to change the table to include additional ones

    # this behavior MAY change in future versions

    #

    # 'sbcs' default value is

    # charset\_table        = 0..9, A..Z-&gt;a..z, \_, a..z, U+A8-&gt;U+B8, U+B8, U+C0..U+DF-&gt;U+E0..U+FF, U+E0..U+FF

    # 转换字符表

    # 'utf-8' default value is

    # charset\_table        = 0..9, A..Z-&gt;a..z, \_, a..z, U+410..U+42F-&gt;U+430..U+44F, U+430..U+44F

 

 

    # ignored characters list

    # optional, default value is empty

    #  忽略字符表

    # ignore\_chars        = U+00AD

 

 

    # minimum word prefix length to index

    # optional, default is 0 (do not index prefixes)

    #索引的最小前缀长度,小心使用,索引和搜索的时间皆会恶化

    # min\_prefix\_len        = 0

 

 

    # minimum word infix length to index

    # optional, default is 0 (do not index infixes)

    #索引的最小中缀长度 小心使用,索引和搜索的时间皆会恶化

    # min\_infix\_len        = 0

 

 

    # list of fields to limit prefix/infix indexing to

    # optional, default value is empty (index all fields in prefix/infix mode)

    # 未知

    # prefix\_fields        = filename

    # infix\_fields        = url, domain

 

 

    # enable star-syntax (wildcards) when searching prefix/infix indexes

    # search-time only, does not affect indexing, can be 0 or 1

    # optional, default is 0 (do not use wildcard syntax)

    # 启用星号语法

    # enable\_star        = 1

 

 

    # expand keywords with exact forms and/or stars when searching fit indexes

    # search-time only, does not affect indexing, can be 0 or 1

    # optional, default is 0 (do not expand keywords)

    # 扩大搜索关键字 形式如: running -&gt; ( running | \*running* | =running )

    # expand\_keywords        = 1

 

 

    # n-gram length to index, for CJK indexing

    # only supports 0 and 1 for now, other lengths to be implemented

    # optional, default is 0 (disable n-grams)

    # 中文等其他语言的基本支持

    # ngram\_len        = 1

 

 

    # n-gram characters list, for CJK indexing

    # optional, default is empty

    #中文或其他语言的值范围

    # ngram\_chars        = U+3000..U+2FA1F

 

 

    # phrase boundary characters list

    # optional, default is empty

    # 边界符

    # phrase\_boundary        = ., ?, !, U+2026 # horizontal ellipsis

 

 

    # phrase boundary word position increment

    # optional, default is 0

    # 边界符增量

    # phrase\_boundary\_step    = 100

 

 

    # blended characters list

    # blended chars are indexed both as separators and valid characters

    # for instance, AT&T will results in 3 tokens ("at", "t", and "at&t")

    # optional, default is empty

    # 混合字符列表

    # blend\_chars        = +, &, U+23

 

 

    # blended token indexing mode

    # a comma separated list of blended token indexing variants

    # known variants are trim\_none, trim\_head, trim\_tail, trim\_both, skip\_pure

    # optional, default is trim\_none

    #未知

    # blend\_mode        = trim\_tail, skip\_pure

 

 

    # whether to strip HTML tags from incoming documents

    # known values are 0 (do not strip) and 1 (do strip)

    # optional, default is 0

    # 删除HTML标签 (小心文本被删除)

    html\_strip        = 0

 

    # what HTML attributes to index if stripping HTML

    # optional, default is empty (do not index anything)

    # 保留的HTML标签

    # html\_index\_attrs    = img=alt,title; a=title;

 

 

    # what HTML elements contents to strip

    # optional, default is empty (do not strip element contents)

    # 不但删除标签,其包含的文本也将删除

    # html\_remove\_elements    = style, script

 

 

    # whether to preopen index data files on startup

    # optional, default is 0 (do not preopen), searchd-only

    # 预先打开索引还是每次查询的时候在打开索引

    # preopen            = 1

 

 

    # whether to keep dictionary (.spi) on disk, or cache it in RAM

    # optional, default is 0 (cache in RAM), searchd-only

    # 将字典文件是否保存在内存中

    # ondisk\_dict        = 1

 

 

    # whether to enable in-place inversion (2x less disk, 90-95% speed)

    # optional, default is 0 (use separate temporary files), indexer-only

    # 是否启用原地索引倒转 将少磁盘使用 性能会有一点损失

    # inplace\_enable        = 1

 

 

    # in-place fine-tuning options

    # optional, defaults are listed below

    #微调原地倒转

    # inplace\_hit\_gap        = 0 # preallocated hitlist gap size 

    # inplace\_docinfo\_gap    = 0 # preallocated docinfo gap size

    # inplace\_reloc\_factor    = 0.1 # relocation buffer size within arena

    # inplace\_write\_factor    = 0.1 # write buffer size within arena

 

 

    # whether to index original keywords along with stemmed versions

    # enables "=exactform" operator to work

    # optional, default is 0

    # 是否在索引原关键词的词干化/重映射后的形式的同时也索引原词

    # index\_exact\_words    = 1

 

 

    # position increment on overshort (less that min\_word\_len) words

    # optional, allowed values are 0 and 1, default is 1

    #在经过过短的词（比 min\_word\_len短的词）处后增加位置值

    # overshort\_step        = 1

 

 

    # position increment on stopword

    # optional, allowed values are 0 and 1, default is 1

    #在经过 停用词 处后增加位置值可选选项

    # stopword\_step        = 1

 

 

    # hitless words list

    # positions for these keywords will not be stored in the index

    # optional, allowed values are 'all', or a list file name

    # 不能中断的字符列表

    # hitless\_words        = all

    # hitless\_words        = hitless.txt #字符文件

 

 

    # detect and index sentence and paragraph boundaries

    # required for the SENTENCE and PARAGRAPH operators to work

    # optional, allowed values are 0 and 1, default is 0

    # 是否检查标签合并 针对HTML

    # index\_sp            = 1

 

 

    # index zones, delimited by HTML/XML tags

    # a comma separated list of tags and wildcards

    # required for the ZONE operator to work

    # optional, default is empty string (do not index zones)

    # 对HTML标签的权重

    # index\_zones        = title, h\*, th

}

 

 

\# inherited index example

\# 索引继承

\# all the parameters are copied from the parent index,

\# and may then be overridden in this index definition

#index test1stemmed : test1

#{

\#    path            = /usr/local/sphinx/var/data/test1stemmed

\#    morphology        = stem\_en

#}

 

 

\# distributed index example

\#

\# this is a virtual index which can NOT be directly indexed,

\# and only contains references to other local and/or remote indexes

#index dist1

#{

#分布式索引配置

    # 'distributed' index type MUST be specified

\#    type            = distributed

 

    # local index to be searched

    # there can be many local indexes configured

\#    local            = test1

\#    local            = test1stemmed

 

    # remote agent

    # multiple remote agents may be specified

    # syntax for TCP connections is 'hostname:port:index1,\[index2\[,...]]'

    # syntax for local UNIX connections is '/path/to/socket:index1,\[index2\[,...]]'

\#    agent            = localhost:9313:remote1

\#    agent            = localhost:9314:remote2,remote3

    # agent            = /var/run/searchd.sock:remote4

 

    # blackhole remote agent, for debugging/testing

    # network errors and search results will be ignored

    #

    # agent\_blackhole        = testbox:9312:testindex1,testindex2

 

 

    # remote agent connection timeout, milliseconds

    # optional, default is 1000 ms, ie. 1 sec

\#    agent\_connect\_timeout    = 1000

 

    # remote agent query timeout, milliseconds

    # optional, default is 3000 ms, ie. 3 sec

\#    agent\_query\_timeout    = 3000

#}

 

 

\# realtime index example

\#

\# you can run INSERT, REPLACE, and DELETE on this index on the fly

\# using MySQL protocol (see 'listen' directive below)

#index rt

#{

    # 'rt' index type must be specified to use RT index

\#    type            = rt

 

    # index files path and file name, without extension

    # mandatory, path must be writable, extensions will be auto-appended

 

\#    path            = /usr/local/sphinx/var/data/rt

 

    # RAM chunk size limit

    # RT index will keep at most this much data in RAM, then flush to disk

    # optional, default is 32M

    #

    # rt\_mem\_limit        = 512M

 

    # full-text field declaration

    # multi-value, mandatory

\#    rt\_field        = title

\#    rt\_field        = content

 

    # unsigned integer attribute declaration

    # multi-value (an arbitrary number of attributes is allowed), optional

    # declares an unsigned 32-bit attribute

\#    rt\_attr\_uint        = gid

 

    # RT indexes currently support the following attribute types:

    # uint, bigint, float, timestamp, string

    #

    # rt\_attr\_bigint        = guid

    # rt\_attr\_float        = gpa

    # rt\_attr\_timestamp    = ts\_added

    # rt\_attr\_string        = author

#}

 

#############################################################################

\## indexer settings

#############################################################################

 

indexer

{

    #索引过程内存使用限制。可选选项，默认32M。 

    # memory limit, in bytes, kiloytes (16384K) or megabytes (256M)

    # optional, default is 32M, max is 2047M, recommended is 256M to 1024M

    mem\_limit        = 32M

 

    # maximum IO calls per second (for I/O throttling)

    # optional, default is 0 (unlimited)

    # 每秒最大I/O操作次数，用于限制I/O操作。可选选项，默认为0（无限制）。 

    # max\_iops        = 40

 

 

    # maximum IO call size, bytes (for I/O throttling)

    # optional, default is 0 (unlimited)

    # 最大允许的I/O操作大小，以字节为单位，用于I/O节流。可选选项，默认为0（不限制）。 

    # max\_iosize        = 1048576

 

 

    # maximum xmlpipe2 field length, bytes

    # optional, default is 2M

    # 对于XMLLpipe2数据源允许的最大的域大小

    # max\_xmlpipe2\_field    = 4M

 

 

    # write buffer size, bytes

    # several (currently up to 4) buffers will be allocated

    # write buffers are allocated in addition to mem\_limit

    # optional, default is 1M

    # 写缓冲区的大小，单位是字节。可选选项，默认值是1MB。 

    # write\_buffer        = 1M

 

 

    # maximum file field adaptive buffer size

    # optional, default is 8M, minimum is 1M

    #

    # max\_file\_field\_buffer    = 32M

}

 

#############################################################################

\## searchd settings

#############################################################################

 

searchd

{

    # \[hostname:]port\[:protocol], or /unix/socket/path to listen on

    # known protocols are 'sphinx' (SphinxAPI) and 'mysql41' (SphinxQL)

    #

    # multi-value, multiple listen points are allowed

    # optional, defaults are 9312:sphinx and 9306:mysql41, as below

    #

    # listen            = 127.0.0.1

    # listen            = 192.168.0.1:9312

    # listen            = 9312

    # listen            = /var/run/searchd.sock

    listen            = 9312

    #listen            = 9306:mysql41

 

    # log file, searchd run info is logged here

    # optional, default is 'searchd.log'

    # 全部searchd运行时事件会被记录在这个日志文件中。 

    log            = /usr/local/sphinx/var/log/searchd.log

 

    # query log file, all search queries are logged here

    # optional, default is empty (do not log queries)

    # 全部搜索查询会被记录在此文件中。

    query\_log        = /usr/local/sphinx/var/log/query.log

 

    # client read timeout, seconds

    # optional, default is 5

    #网络客户端请求的读超时时间，单位是秒。

    read\_timeout        = 5

 

    # request timeout, seconds

    # optional, default is 5 minutes

    #在使用持久连接时，两次查询之间等待的最长时间（单位是秒）。

    client\_timeout        = 300

 

    # maximum amount of children to fork (concurrent searches to run)

    # optional, default is 0 (unlimited)

    #子进程的最大数量 ,用来控制服务器负载。任何时候不可能有比此设置值更多的搜索同时运行。当达到限制时，新的输入客户端会被用临时失败（SEARCH\_RETRY）状态码驳回，同时给出一个声明服务器已到最大连接限制的消息。 

    max\_children        = 30

 

    # PID file, searchd process ID file name

    # mandatory

    #进程ID文件

    pid\_file        = /usr/local/sphinx/var/log/searchd.pid

 

    # max amount of matches the daemon ever keeps in RAM, per-index

    # WARNING, THERE'S ALSO PER-QUERY LIMIT, SEE SetLimits() API CALL

    # default is 1000 (just like Google)

    #守护进程在内存中为每个索引所保持并返回给客户端的匹配数目的最大值。

    max\_matches        = 1000

 

    # seamless rotate, prevents rotate stalls if precaching huge datasets

    # optional, default is 1

    #防止 searchd 轮换在需要预取大量数据的索引时停止响应。可选选项，默认为1（启用无缝（seamless）轮换）。 

    seamless\_rotate        = 1

 

    # whether to forcibly preopen all indexes on startup

    # optional, default is 1 (preopen everything)

    #是否在启动是强制重新打开所有索引文件。可选选项，默认为0（不重新打开）。

    preopen\_indexes        = 1

 

    # whether to unlink .old index copies on succesful rotation.

    # optional, default is 1 (do unlink)

    #索引轮换成功之后，是否删除以.old为扩展名的索引拷贝。可选选项，默认为1（删除这些索引拷贝）。 

    unlink\_old        = 1

 

    # attribute updates periodic flush timeout, seconds

    # updates will be automatically dumped to disk this frequently

    # optional, default is 0 (disable periodic flush)

    # UpdateAttributes() 调用时候更新是否隔一段时间写入磁盘

    # attr\_flush\_period    = 900

 

 

    # instance-wide ondisk\_dict defaults (per-index value take precedence)

    # optional, default is 0 (precache all dictionaries in RAM)

    #对 ondisk\_dict 指令的全局的默认值。 可选选项，默认值是0（将字典预先缓冲到内存）。

    # ondisk\_dict\_default    = 1

 

 

    # MVA updates pool size

    # shared between all instances of searchd, disables attr flushes!

    # optional, default size is 1M

    #网络通讯时允许的最大的包的大小。

    mva\_updates\_pool    = 1M

 

    # max allowed network packet size

    # limits both query packets from clients, and responses from agents

    # optional, default size is 8M

    #用于多值属性MVA更新的存储空间的共享池大小。

    max\_packet\_size        = 8M

 

    # crash log path

    # searchd will (try to) log crashed query to 'crash\_log\_path.PID' file

    # optional, default is empty (do not create crash logs)

    #崩溃日志文件的路径

    # crash\_log\_path        = /usr/local/sphinx/var/log/crash

 

 

    # max allowed per-query filter count

    # optional, default is 256

    #每次查询允许设置的过滤器的最大个数。只用于内部检查，不直接影响内存使用或性能。

    max\_filters        = 256

 

    # max allowed per-filter values count

    # optional, default is 4096

    #单个过滤器允许的值的最大个数。只用于内部检查，不直接影响内存使用或性能。

    max\_filter\_values    = 4096

 

 

    # socket listen queue length

    # optional, default is 5

    #TCP监听积压列表长度。无法如对的请求立即失败并收到“连接被拒”错误信息

    # listen\_backlog        = 5

 

 

    # per-keyword read buffer size

    # optional, default is 256K

    #每个关键字的读缓冲区的大小。可选选项，默认值是256K。 

    # read\_buffer        = 256K

 

 

    # unhinted read size (currently used when reading hits)

    # optional, default is 32K

    #无提示时读操作的大小。可选选项，默认值是32K。

    # read\_unhinted        = 32K

 

 

    # max allowed per-batch query count (aka multi-query count)

    # optional, default is 32

    #限制每批次的查询量。一个OPEN之后的查询量

    max\_batch\_queries    = 32

 

 

    # max common subtree document cache size, per-query

    # optional, default is 0 (disable subtree optimization)

    #

    # subtree\_docs\_cache    = 4M

 

 

    # max common subtree hit cache size, per-query

    # optional, default is 0 (disable subtree optimization)

    # 限制RAM使用一个共同的子树优化 默认不优化

    # subtree\_hits\_cache    = 8M

 

 

    # multi-processing mode (MPM)

    # known values are none, fork, prefork, and threads

    # optional, default is fork

    # 工作方式 

    workers            = threads # for RT to work

 

 

    # max threads to create for searching local parts of a distributed index

    # optional, default is 0, which means disable multi-threaded searching

    # should work with all MPMs (ie. does NOT require workers=threads)

    #  

    # dist\_threads        = 4

 

 

    # binlog files path; use empty string to disable binlog

    # optional, default is build-time configured data directory

    # 二进制日志路径

    # binlog\_path        = # disable logging

    # binlog\_path        = /usr/local/sphinx/var/data # binlog.001 etc will be created there

 

 

    # binlog flush/sync mode

    # 0 means flush and sync every second

    # 1 means flush and sync every transaction

    # 2 means flush every transaction, sync every second

    # optional, default is 2

    # 日志刷新模式

    # binlog\_flush        = 2

 

 

    # binlog per-file size limit

    # optional, default is 128M, 0 means no limit

    #最大日志大小

    # binlog\_max\_log\_size    = 256M

 

 

    # per-thread stack size, only affects workers=threads mode

    # optional, default is 64K

    #每个线程的堆栈大小。

    # thread\_stack            = 128K

 

 

    # per-keyword expansion limit (for dict=keywords prefix searches)

    # optional, default is 0 (no limit)

    # 扩大为一个关键字的最大数目

    # expansion\_limit        = 1000

 

 

    # RT RAM chunks flush period

    # optional, default is 0 (no periodic flush)

    #RT索引在内存中检查的时间

    # rt\_flush\_period        = 900

 

 

    # query log file format

    # optional, known values are plain and sphinxql, default is plain

    # 查询日志格式

    # query\_log\_format        = sphinxql

 

 

    # version string returned to MySQL network protocol clients

    # optional, default is empty (use Sphinx version)

    # MYSQL版本

    # mysql\_version\_string    = 5.0.37

 

 

    # trusted plugin directory

    # optional, default is empty (disable UDFs)

    # 插件目录

    # plugin\_dir            = /usr/local/sphinx/lib

 

 

    # default server-wide collation

    # optional, default is libc\_ci

    # 链接字符集

    # collation\_server        = utf8\_general\_ci

 

 

    # server-wide locale for libc based collations

    # optional, default is C

    # collation 选项

    # collation\_libc\_locale    = ru\_RU.UTF-8

 

 

    # threaded server watchdog (only used in workers=threads mode)

    # optional, values are 0 and 1, default is 1 (watchdog on)

    # 是否启用服务器监控进程

    # watchdog                = 1

 

 

    # SphinxQL compatibility mode (legacy columns and their names)

    # optional, default is 0 (SQL compliant syntax and result sets)

    #sphinxql 兼容模式

    # compat\_sphinxql\_magics    = 1

}

 

\# --eof--