<转> php sphinx 详细配置

转:http://blog.csdn.net/adparking/article/details/7207119

1.下载PHP客户端安装:

http://pecl.php.net/package/sphinx

 

vim sphinxclient.c                    
找到
void sock_close ( int sock );
改为
static void sock_close ( int sock );

 


 php.ini加扩展,客户端安装完毕

2.安装sphinx,前提你已经安装mysql且安装了mysql-devel重源码安装mysql

mysql-devel都已经安装,yum安装的运行
yum -y install mysql-devel

下载sphinx2.0.1地址:  

http://sphinxsearch.com/downloads/

 

tar -xvzf sphinx-2.0.1-beta.tar.gz
cd sphinx-2.0.1-beta
./configure --prefix=/usr/local/sphinx --with-mysql --with-iconv

 

备注:64位增加参数 --enable-id64


make && make install cd /usr/local/sphinx/etc/ cp sphinx.conf.dist sphinx.conf

 

  1. #  
  2. # Sphinx configuration file sample  
  3. #  
  4. # WARNING! While this sample file mentions all available options,  
  5. # it contains (very) short helper descriptions only. Please refer to  
  6. # doc/sphinx.html for details.  
  7. #  
  8.   
  9. #############################################################################  
  10. ## data source definition  
  11. #############################################################################  
  12.   
  13. source src1  
  14. {  
  15.     # data source type. mandatory, no default value  
  16.     # known types are mysql, pgsql, mssql, xmlpipe, xmlpipe2, odbc  
  17.     type            = mysql  
  18.   
  19.     #####################################################################  
  20.     ## SQL settings (for 'mysql' and 'pgsql' types)  
  21.     #####################################################################  
  22.   
  23.     # some straightforward parameters for SQL source types  
  24.     sql_host        = localhost  
  25.     sql_user        = root  
  26.     sql_pass        = ******   
  27.     sql_db            = ******  
  28.     sql_port        = 3306    # optional, default is 3306  
  29.   
  30.     # UNIX socket name  
  31.     # optional, default is empty (reuse client library defaults)  
  32.     # usually '/var/lib/mysql/mysql.sock' on Linux  
  33.     # usually '/tmp/mysql.sock' on FreeBSD  
  34.     #  
  35.     sql_sock        = /tmp/mysql.sock  
  36.   
  37.   
  38.     # MySQL specific client connection flags  
  39.     # optional, default is 0  
  40.     # 数据传输方式  
  41.     # mysql_connect_flags    = 32 # enable compression  
  42.   
  43.     # MySQL specific SSL certificate settings  
  44.     # optional, defaults are empty  
  45.     # SLL链接  
  46.     # mysql_ssl_cert        = /etc/ssl/client-cert.pem  
  47.     # mysql_ssl_key        = /etc/ssl/client-key.pem  
  48.     # mysql_ssl_ca        = /etc/ssl/cacert.pem  
  49.   
  50.     # MS SQL specific Windows authentication mode flag  
  51.     # MUST be in sync with charset_type index-level setting  
  52.     # optional, default is 0  
  53.     #  
  54.     # mssql_winauth        = 1 # use currently logged on user credentials  
  55.   
  56.   
  57.     # MS SQL specific Unicode indexing flag  
  58.     # optional, default is 0 (request SBCS data)  
  59.     #  
  60.     # mssql_unicode        = 1 # request Unicode data from server  
  61.   
  62.   
  63.     # ODBC specific DSN (data source name)  
  64.     # mandatory for odbc source type, no default value  
  65.     #  
  66.     # odbc_dsn        = DBQ=C:\data;DefaultDir=C:\data;Driver={Microsoft Text Driver (*.txt; *.csv)};  
  67.     # sql_query        = SELECT id, data FROM documents.csv  
  68.   
  69.   
  70.     # ODBC and MS SQL specific, per-column buffer sizes  
  71.     # optional, default is auto-detect  
  72.     #  
  73.     # sql_column_buffers    = content=12M, comments=1M  
  74.   
  75.   
  76.     # pre-query, executed before the main fetch query  
  77.     # multi-value, optional, default is empty list of queries  
  78.     # 发送SQL语句前发送  
  79.     sql_query_pre        = SET NAMES utf8  
  80.     sql_query_pre        = SET SESSION query_cache_type=OFF  
  81.   
  82.   
  83.     # main document fetch query  
  84.     # mandatory, integer document ID field MUST be the first selected column  
  85.     # 需要查询的表 构建查询  
  86.     sql_query        = \  
  87.         SELECT id,target_type,genre,stars,sub_title,sports_team,music_band,music_album \  
  88.         FROM ko_link  
  89. #如果多个数据源并要在一个索引,必须要保持字段的顺序数量跟数据都要一致,否则将出错  
  90.   
  91.   
  92.     # joined/payload field fetch query  
  93.     # joined fields let you avoid (slow) JOIN and GROUP_CONCAT  
  94.     # payload fields let you attach custom per-keyword values (eg. for ranking)  
  95.     #  
  96.     # syntax is FIELD-NAME 'from'  ( 'query' | 'payload-query' ); QUERY  
  97.     # joined field QUERY should return 2 columns (docid, text)  
  98.     # payload field QUERY should return 3 columns (docid, keyword, weight)  
  99.     #  
  100.     # REQUIRES that query results are in ascending docuent ID order!  
  101.     # multi-value, optional, default is empty list of queries  
  102.     #  添加字段,来源与表 自动连接  
  103. # 字段结果集保持为  
  104. # (1,tags1)  
  105. # (1,tags2)  
  106. # (2,tags3)  
  107. # (2,tags4)  
  108. # 添加字段将用于搜索,结果如有第3个字段,第3个字段表示该记录的权重,权重为大于1的值  
  109.     # sql_joined_field    = tags from query; SELECT docid, CONCAT('tag',tagid) FROM tags ORDER BY docid ASC  
  110.     # sql_joined_field    = wtags from payload-query; SELECT docid, tag, tagweight FROM tags ORDER BY docid ASC  
  111.   
  112.   
  113.     # file based field declaration  
  114.     #  
  115.     # content of this field is treated as a file name  
  116.     # and the file gets loaded and indexed in place of a field  
  117.     #  
  118.     # max file size is limited by max_file_field_buffer indexer setting  
  119.     # file IO errors are non-fatal and get reported as warnings  
  120.     # 把字段声明放入文件  
  121.     # sql_file_field        = content_file_path  
  122.   
  123.   
  124.     # range query setup, query that must return min and max ID values  
  125.     # optional, default is empty  
  126.     #   
  127.     # sql_query will need to reference $start and $end boundaries  
  128.     # if using ranged query:  
  129.     # 分区查询,防止MYSQL死锁  
  130.     # sql_query        = \  
  131.     #    SELECT doc.id, doc.id AS group, doc.title, doc.data \  
  132.     #    FROM documents doc \  
  133.     #    WHERE id>=$start AND id<=$end  
  134.     #  
  135.     # sql_query_range        = SELECT MIN(id),MAX(id) FROM documents  
  136.   
  137.   
  138.     # range query step  
  139.     # optional, default is 1024  
  140.     # 分区查询跳步  
  141.     # sql_range_step        = 1000  
  142.   
  143.       
  144.       
  145.       
  146.     # unsigned integer attribute declaration  
  147.     # multi-value (an arbitrary number of attributes is allowed), optional  
  148.     # optional bit size can be specified, default is 32  
  149.     # 声明无符号数字段  
  150.     #sql_attr_uint        = target_type  
  151.     # sql_attr_uint        = forum_id:9 # 9 bits for forum_id  
  152.     #sql_attr_uint        = group_id  
  153.     #声明BOOL字段  
  154.     # boolean attribute declaration  
  155.     # multi-value (an arbitrary number of attributes is allowed), optional  
  156.     # equivalent to sql_attr_uint with 1-bit size  
  157.     #  
  158.     # sql_attr_bool        = is_deleted  
  159.   
  160.   
  161.     # bigint attribute declaration  
  162.     # multi-value (an arbitrary number of attributes is allowed), optional  
  163.     # declares a signed (unlike uint!) 64-bit attribute  
  164.     # 声明长整字段  
  165.     # sql_attr_bigint        = my_bigint_id  
  166.   
  167.   
  168.     # UNIX timestamp attribute declaration  
  169.     # multi-value (an arbitrary number of attributes is allowed), optional  
  170.     # similar to integer, but can also be used in date functions  
  171.     # 声明时间字段  
  172.     # sql_attr_timestamp    = posted_ts  
  173.     # sql_attr_timestamp    = last_edited_ts  
  174.     #sql_attr_timestamp    = date_added  
  175.       
  176.     # string ordinal attribute declaration  
  177.     # multi-value (an arbitrary number of attributes is allowed), optional  
  178.     # sorts strings (bytewise), and stores their indexes in the sorted list  
  179.     # sorting by this attr is equivalent to sorting by the original strings  
  180.     # 声明字符串字段 用于排序等,但此字段不会被存储  
  181.     # sql_attr_str2ordinal    = author_name  
  182.   
  183.   
  184.     # floating point attribute declaration  
  185.     # multi-value (an arbitrary number of attributes is allowed), optional  
  186.     # values are stored in single precision, 32-bit IEEE 754 format  
  187.     # 声明浮点字段  
  188.     # sql_attr_float        = lat_radians  
  189.     # sql_attr_float        = long_radians  
  190.   
  191.   
  192.     # multi-valued attribute (MVA) attribute declaration  
  193.     # multi-value (an arbitrary number of attributes is allowed), optional  
  194.     # MVA values are variable length lists of unsigned 32-bit integers  
  195.     #  
  196.     # syntax is ATTR-TYPE ATTR-NAME 'from' SOURCE-TYPE [;QUERY] [;RANGE-QUERY]  
  197.     # ATTR-TYPE is 'uint' or 'timestamp'  
  198.     # SOURCE-TYPE is 'field', 'query', or 'ranged-query'  
  199.     # QUERY is SQL query used to fetch all ( docid, attrvalue ) pairs  
  200.     # RANGE-QUERY is SQL query used to fetch min and max ID values, similar to 'sql_query_range'  
  201.     # 声明复合字段  
  202.     # sql_attr_multi        = uint tag from query; SELECT docid, tagid FROM tags  
  203.     # sql_attr_multi        = uint tag from ranged-query; \  
  204.     #    SELECT docid, tagid FROM tags WHERE id>=$start AND id<=$end; \  
  205.     #    SELECT MIN(docid), MAX(docid) FROM tags  
  206.   
  207.   
  208.     # string attribute declaration  
  209.     # multi-value (an arbitrary number of these is allowed), optional  
  210.     # lets you store and retrieve strings  
  211.     # 只是把数据存储,但不会索引改字段  
  212.     # sql_attr_string        = stitle  
  213.   
  214.   
  215.     # wordcount attribute declaration  
  216.     # multi-value (an arbitrary number of these is allowed), optional  
  217.     # lets you count the words at indexing time  
  218.     # 将转化成关键字的字段,用于提高匹配率  
  219.     # sql_attr_str2wordcount    = stitle  
  220.   
  221.   
  222.     # combined field plus attribute declaration (from a single column)  
  223.     # stores column as an attribute, but also indexes it as a full-text field  
  224.     # 跟sql_attr_string不同是该属性加入索引  
  225.     # sql_field_string    = author  
  226.     # sql_field_str2wordcount    = title  
  227.   
  228.       
  229.     # post-query, executed on sql_query completion  
  230.     # optional, default is empty  
  231.     # 取后查询  
  232.     # sql_query_post        =  
  233.   
  234.       
  235.     # post-index-query, executed on successful indexing completion  
  236.     # optional, default is empty  
  237.     # $maxid expands to max document ID actually fetched from DB  
  238.     # 索引后查询  
  239.     # sql_query_post_index    = REPLACE INTO counters ( id, val ) \  
  240.     #    VALUES ( 'max_indexed_id', $maxid )  
  241.   
  242.   
  243.     # ranged query throttling, in milliseconds  
  244.     # optional, default is 0 which means no delay  
  245.     # enforces given delay before each query step  
  246.     #分区查询的时间间隔  
  247.     sql_ranged_throttle    = 0  
  248.   
  249.     # document info query, ONLY for CLI search (ie. testing and debugging)  
  250.     # optional, default is empty  
  251.     # must contain $id macro and must fetch the document by that id  
  252.     #命令行调试查询结果用  
  253.     sql_query_info        = SELECT * FROM ko_link WHERE id=$id  
  254.   
  255.     # kill-list query, fetches the document IDs for kill-list  
  256.     # k-list will suppress matches from preceding indexes in the same query  
  257.     # optional, default is empty  
  258.     ##清理指定查询ID列表,对于数据的更改  
  259.     # sql_query_killlist    = SELECT id FROM documents WHERE edited>=@last_reindex  
  260.   
  261.   
  262.     # columns to unpack on indexer side when indexing  
  263.     # multi-value, optional, default is empty list  
  264.     # 启用ZIP压缩 可以降低系统负载 但必须保证zlib库zlib-dev库可用  
  265.     # unpack_zlib        = zlib_column  
  266.     # unpack_mysqlcompress    = compressed_column  
  267.     # unpack_mysqlcompress    = compressed_column_2  
  268.   
  269.   
  270.     # maximum unpacked length allowed in MySQL COMPRESS() unpacker  
  271.     # optional, default is 16M  
  272.     # 压缩缓存区大小 不能小于字段存储值  
  273.     # unpack_mysqlcompress_maxsize    = 16M  
  274.   
  275.   
  276.     #####################################################################  
  277.     ## xmlpipe2 配置  
  278.     #####################################################################  
  279.   
  280.     # type            = xmlpipe  
  281.   
  282.     # shell command to invoke xmlpipe stream producer  
  283.     # mandatory  
  284.     #  
  285.     # xmlpipe_command        = cat /usr/local/sphinx/var/test.xml  
  286.   
  287.     # xmlpipe2 field declaration  
  288.     # multi-value, optional, default is empty  
  289.     #  
  290.     # xmlpipe_field        = subject  
  291.     # xmlpipe_field        = content  
  292.   
  293.   
  294.     # xmlpipe2 attribute declaration  
  295.     # multi-value, optional, default is empty  
  296.     # all xmlpipe_attr_XXX options are fully similar to sql_attr_XXX  
  297.     #  
  298.     # xmlpipe_attr_timestamp    = published  
  299.     # xmlpipe_attr_uint    = author_id  
  300.   
  301.   
  302.     # perform UTF-8 validation, and filter out incorrect codes  
  303.     # avoids XML parser choking on non-UTF-8 documents  
  304.     # optional, default is 0  
  305.     #  
  306.     # xmlpipe_fixup_utf8    = 1  
  307. }  
  308.   
  309.   
  310. # inherited source example  
  311. # 继承数据源  
  312. # all the parameters are copied from the parent source,  
  313. and may then be overridden in this source definition  
  314. #source src1throttled : src1  
  315. #{  
  316. #    sql_ranged_throttle    = 100  
  317. #}  
  318.   
  319. #############################################################################  
  320. ## index definition  
  321. #############################################################################  
  322.   
  323. # local index example  
  324. #  
  325. # this is an index which is stored locally in the filesystem  
  326. #  
  327. # all indexing-time options (such as morphology and charsets)  
  328. # are configured per local index  
  329. index test1  
  330. {  
  331.     # index type  
  332.     # optional, default is 'plain'  
  333.     # known values are 'plain', 'distributed', and 'rt' (see samples below)   
  334.     #索引类型 本地 分布式   
  335.     # type            = plain  
  336.   
  337.     # document source(s) to index  
  338.     # multi-value, mandatory  
  339.     # document IDs must be globally unique across all sources  
  340.     #数据源,可以多个数据源  
  341.     source            = src1  
  342.   
  343.     # index files path and file name, without extension  
  344.     # mandatory, path must be writable, extensions will be auto-appended  
  345.     # 索引保存路径  
  346.     path            = /usr/local/sphinx/var/data/test1  
  347.   
  348.     # document attribute values (docinfo) storage mode  
  349.     # optional, default is 'extern'  
  350.     # known values are 'none', 'extern' and 'inline'  
  351.     #索引存储方式  
  352.     docinfo            = extern  
  353.   
  354.     # memory locking for cached data (.spa and .spi), to prevent swapping  
  355.     # optional, default is 0 (do not mlock)  
  356.     # requires searchd to be run from root  
  357.     #内存锁定 需要保证足够权限  
  358.     mlock            = 0  
  359.   
  360.     # a list of morphology preprocessors to apply  
  361.     # optional, default is empty  
  362.     #  
  363.     # builtin preprocessors are 'none', 'stem_en', 'stem_ru', 'stem_enru',  
  364.     # 'soundex', and 'metaphone'; additional preprocessors available from  
  365.     # libstemmer are 'libstemmer_XXX', where XXX is algorithm code  
  366.     # (see libstemmer_c/libstemmer/modules.txt)  
  367.     # 词语提取器  
  368.     # morphology        = stem_en, stem_ru, soundex  
  369.     # morphology        = libstemmer_german  
  370.     # morphology        = libstemmer_sv  
  371.     morphology        = stem_en  
  372.   
  373.     # minimum word length at which to enable stemming  
  374.     # optional, default is 1 (stem everything)  
  375.     # 词干化的最小词长  
  376.     # min_stemming_len    = 1  
  377.   
  378.   
  379.     # stopword files list (space separated)  
  380.     # optional, default is empty  
  381.     # contents are plain text, charset_table and stemming are both applied  
  382.     # 停用搜索词  
  383.     # stopwords        = /usr/local/sphinx/var/data/stopwords.txt  
  384.   
  385.   
  386.     # wordforms file, in "mapfrom > mapto" plain text format  
  387.     # optional, default is empty  
  388.     # 词型字典 可用spelldump工具生成  
  389.     # wordforms        = /usr/local/sphinx/var/data/wordforms.txt  
  390.   
  391.   
  392.     # tokenizing exceptions file  
  393.     # optional, default is empty  
  394.     #Token特例文件,就是有些词是完整词意,不能拆分索引如a&t 跟a & t  
  395.     # plain text, case sensitive, space insensitive in map-from part  
  396.     # one "Map Several Words => ToASingleOne" entry per line  
  397.     #  
  398.     # exceptions        = /usr/local/sphinx/var/data/exceptions.txt  
  399.   
  400.   
  401.     # minimum indexed word length  
  402.     # default is 1 (index everything)  
  403.     #  最小索引长度,就是小于指定长度的词不被索引  
  404.     min_word_len        = 1  
  405.   
  406.     # charset encoding type  
  407.     # optional, default is 'sbcs'  
  408.     # known types are 'sbcs' (Single Byte CharSet) and 'utf-8'  
  409.     # 字符编码  
  410.     charset_type        = utf-8  
  411.   
  412.     # charset definition and case folding rules "table"  
  413.     # optional, default value depends on charset_type  
  414.     #  
  415.     # defaults are configured to include English and Russian characters only  
  416.     # you need to change the table to include additional ones  
  417.     # this behavior MAY change in future versions  
  418.     #  
  419.     # 'sbcs' default value is  
  420.     # charset_table        = 0..9, A..Z->a..z, _, a..z, U+A8->U+B8, U+B8, U+C0..U+DF->U+E0..U+FF, U+E0..U+FF  
  421.     # 转换字符表  
  422.     # 'utf-8' default value is  
  423.     # charset_table        = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F  
  424.   
  425.   
  426.     # ignored characters list  
  427.     # optional, default value is empty  
  428.     #  忽略字符表  
  429.     # ignore_chars        = U+00AD  
  430.   
  431.   
  432.     # minimum word prefix length to index  
  433.     # optional, default is 0 (do not index prefixes)  
  434.     #索引的最小前缀长度,小心使用,索引和搜索的时间皆会恶化  
  435.     # min_prefix_len        = 0  
  436.   
  437.   
  438.     # minimum word infix length to index  
  439.     # optional, default is 0 (do not index infixes)  
  440.     #索引的最小中缀长度 小心使用,索引和搜索的时间皆会恶化  
  441.     # min_infix_len        = 0  
  442.   
  443.   
  444.     # list of fields to limit prefix/infix indexing to  
  445.     # optional, default value is empty (index all fields in prefix/infix mode)  
  446.     # 未知  
  447.     # prefix_fields        = filename  
  448.     # infix_fields        = url, domain  
  449.   
  450.   
  451.     # enable star-syntax (wildcards) when searching prefix/infix indexes  
  452.     # search-time only, does not affect indexing, can be 0 or 1  
  453.     # optional, default is 0 (do not use wildcard syntax)  
  454.     # 启用星号语法  
  455.     # enable_star        = 1  
  456.   
  457.   
  458.     # expand keywords with exact forms and/or stars when searching fit indexes  
  459.     # search-time only, does not affect indexing, can be 0 or 1  
  460.     # optional, default is 0 (do not expand keywords)  
  461.     # 扩大搜索关键字 形式如: running -> ( running | *running* | =running )  
  462.     # expand_keywords        = 1  
  463.   
  464.       
  465.     # n-gram length to index, for CJK indexing  
  466.     # only supports 0 and 1 for now, other lengths to be implemented  
  467.     # optional, default is 0 (disable n-grams)  
  468.     # 中文等其他语言的基本支持  
  469.     # ngram_len        = 1  
  470.   
  471.   
  472.     # n-gram characters list, for CJK indexing  
  473.     # optional, default is empty  
  474.     #中文或其他语言的值范围  
  475.     # ngram_chars        = U+3000..U+2FA1F  
  476.   
  477.   
  478.     # phrase boundary characters list  
  479.     # optional, default is empty  
  480.     # 边界符  
  481.     # phrase_boundary        = ., ?, !, U+2026 # horizontal ellipsis  
  482.   
  483.   
  484.     # phrase boundary word position increment  
  485.     # optional, default is 0  
  486.     # 边界符增量  
  487.     # phrase_boundary_step    = 100  
  488.   
  489.   
  490.     # blended characters list  
  491.     # blended chars are indexed both as separators and valid characters  
  492.     # for instance, AT&T will results in 3 tokens ("at", "t", and "at&t")  
  493.     # optional, default is empty  
  494.     # 混合字符列表  
  495.     # blend_chars        = +, &, U+23  
  496.   
  497.   
  498.     # blended token indexing mode  
  499.     # a comma separated list of blended token indexing variants  
  500.     # known variants are trim_none, trim_head, trim_tail, trim_both, skip_pure  
  501.     # optional, default is trim_none  
  502.     #未知  
  503.     # blend_mode        = trim_tail, skip_pure  
  504.   
  505.   
  506.     # whether to strip HTML tags from incoming documents  
  507.     # known values are 0 (do not strip) and 1 (do strip)  
  508.     # optional, default is 0  
  509.     # 删除HTML标签 (小心文本被删除)  
  510.     html_strip        = 0  
  511.   
  512.     # what HTML attributes to index if stripping HTML  
  513.     # optional, default is empty (do not index anything)  
  514.     # 保留的HTML标签  
  515.     # html_index_attrs    = img=alt,title; a=title;  
  516.   
  517.   
  518.     # what HTML elements contents to strip  
  519.     # optional, default is empty (do not strip element contents)  
  520.     # 不但删除标签,其包含的文本也将删除  
  521.     # html_remove_elements    = style, script  
  522.   
  523.   
  524.     # whether to preopen index data files on startup  
  525.     # optional, default is 0 (do not preopen), searchd-only  
  526.     # 预先打开索引还是每次查询的时候在打开索引  
  527.     # preopen            = 1  
  528.   
  529.   
  530.     # whether to keep dictionary (.spi) on disk, or cache it in RAM  
  531.     # optional, default is 0 (cache in RAM), searchd-only  
  532.     # 将字典文件是否保存在内存中  
  533.     # ondisk_dict        = 1  
  534.   
  535.   
  536.     # whether to enable in-place inversion (2x less disk, 90-95% speed)  
  537.     # optional, default is 0 (use separate temporary files), indexer-only  
  538.     # 是否启用原地索引倒转 将少磁盘使用 性能会有一点损失  
  539.     # inplace_enable        = 1  
  540.   
  541.   
  542.     # in-place fine-tuning options  
  543.     # optional, defaults are listed below  
  544.     #微调原地倒转  
  545.     # inplace_hit_gap        = 0 # preallocated hitlist gap size   
  546.     # inplace_docinfo_gap    = 0 # preallocated docinfo gap size  
  547.     # inplace_reloc_factor    = 0.1 # relocation buffer size within arena  
  548.     # inplace_write_factor    = 0.1 # write buffer size within arena  
  549.   
  550.   
  551.     # whether to index original keywords along with stemmed versions  
  552.     # enables "=exactform" operator to work  
  553.     # optional, default is 0  
  554.     # 是否在索引原关键词的词干化/重映射后的形式的同时也索引原词  
  555.     # index_exact_words    = 1  
  556.   
  557.   
  558.     # position increment on overshort (less that min_word_len) words  
  559.     # optional, allowed values are 0 and 1, default is 1  
  560.     #在经过过短的词(比 min_word_len短的词)处后增加位置值  
  561.     # overshort_step        = 1  
  562.   
  563.   
  564.     # position increment on stopword  
  565.     # optional, allowed values are 0 and 1, default is 1  
  566.     #在经过 停用词 处后增加位置值可选选项  
  567.     # stopword_step        = 1  
  568.   
  569.   
  570.     # hitless words list  
  571.     # positions for these keywords will not be stored in the index  
  572.     # optional, allowed values are 'all', or a list file name  
  573.     # 不能中断的字符列表  
  574.     # hitless_words        = all  
  575.     # hitless_words        = hitless.txt #字符文件  
  576.   
  577.   
  578.     # detect and index sentence and paragraph boundaries  
  579.     # required for the SENTENCE and PARAGRAPH operators to work  
  580.     # optional, allowed values are 0 and 1, default is 0  
  581.     # 是否检查标签合并 针对HTML  
  582.     # index_sp            = 1  
  583.   
  584.   
  585.     # index zones, delimited by HTML/XML tags  
  586.     # a comma separated list of tags and wildcards  
  587.     # required for the ZONE operator to work  
  588.     # optional, default is empty string (do not index zones)  
  589.     # 对HTML标签的权重  
  590.     # index_zones        = title, h*, th  
  591. }  
  592.   
  593.   
  594. # inherited index example  
  595. # 索引继承  
  596. # all the parameters are copied from the parent index,  
  597. and may then be overridden in this index definition  
  598. #index test1stemmed : test1  
  599. #{  
  600. #    path            = /usr/local/sphinx/var/data/test1stemmed  
  601. #    morphology        = stem_en  
  602. #}  
  603.   
  604.   
  605. # distributed index example  
  606. #  
  607. # this is a virtual index which can NOT be directly indexed,  
  608. and only contains references to other local and/or remote indexes  
  609. #index dist1  
  610. #{  
  611. #分布式索引配置  
  612.     # 'distributed' index type MUST be specified  
  613. #    type            = distributed  
  614.   
  615.     # local index to be searched  
  616.     # there can be many local indexes configured  
  617. #    local            = test1  
  618. #    local            = test1stemmed  
  619.   
  620.     # remote agent  
  621.     # multiple remote agents may be specified  
  622.     # syntax for TCP connections is 'hostname:port:index1,[index2[,...]]'  
  623.     # syntax for local UNIX connections is '/path/to/socket:index1,[index2[,...]]'  
  624. #    agent            = localhost:9313:remote1  
  625. #    agent            = localhost:9314:remote2,remote3  
  626.     # agent            = /var/run/searchd.sock:remote4  
  627.   
  628.     # blackhole remote agent, for debugging/testing  
  629.     # network errors and search results will be ignored  
  630.     #  
  631.     # agent_blackhole        = testbox:9312:testindex1,testindex2  
  632.   
  633.   
  634.     # remote agent connection timeout, milliseconds  
  635.     # optional, default is 1000 ms, ie. 1 sec  
  636. #    agent_connect_timeout    = 1000  
  637.   
  638.     # remote agent query timeout, milliseconds  
  639.     # optional, default is 3000 ms, ie. 3 sec  
  640. #    agent_query_timeout    = 3000  
  641. #}  
  642.   
  643.   
  644. # realtime index example  
  645. #  
  646. # you can run INSERT, REPLACE, and DELETE on this index on the fly  
  647. # using MySQL protocol (see 'listen' directive below)  
  648. #index rt  
  649. #{  
  650.     # 'rt' index type must be specified to use RT index  
  651. #    type            = rt  
  652.   
  653.     # index files path and file name, without extension  
  654.     # mandatory, path must be writable, extensions will be auto-appended  
  655.   
  656. #    path            = /usr/local/sphinx/var/data/rt  
  657.   
  658.     # RAM chunk size limit  
  659.     # RT index will keep at most this much data in RAM, then flush to disk  
  660.     # optional, default is 32M  
  661.     #  
  662.     # rt_mem_limit        = 512M  
  663.   
  664.     # full-text field declaration  
  665.     # multi-value, mandatory  
  666. #    rt_field        = title  
  667. #    rt_field        = content  
  668.   
  669.     # unsigned integer attribute declaration  
  670.     # multi-value (an arbitrary number of attributes is allowed), optional  
  671.     # declares an unsigned 32-bit attribute  
  672. #    rt_attr_uint        = gid  
  673.   
  674.     # RT indexes currently support the following attribute types:  
  675.     # uint, bigint, float, timestamp, string  
  676.     #  
  677.     # rt_attr_bigint        = guid  
  678.     # rt_attr_float        = gpa  
  679.     # rt_attr_timestamp    = ts_added  
  680.     # rt_attr_string        = author  
  681. #}  
  682.   
  683. #############################################################################  
  684. ## indexer settings  
  685. #############################################################################  
  686.   
  687. indexer  
  688. {  
  689.     #索引过程内存使用限制。可选选项,默认32M。   
  690.     # memory limit, in bytes, kiloytes (16384K) or megabytes (256M)  
  691.     # optional, default is 32M, max is 2047M, recommended is 256M to 1024M  
  692.     mem_limit        = 32M  
  693.   
  694.     # maximum IO calls per second (for I/O throttling)  
  695.     # optional, default is 0 (unlimited)  
  696.     # 每秒最大I/O操作次数,用于限制I/O操作。可选选项,默认为0(无限制)。   
  697.     # max_iops        = 40  
  698.   
  699.   
  700.     # maximum IO call size, bytes (for I/O throttling)  
  701.     # optional, default is 0 (unlimited)  
  702.     # 最大允许的I/O操作大小,以字节为单位,用于I/O节流。可选选项,默认为0(不限制)。   
  703.     # max_iosize        = 1048576  
  704.   
  705.   
  706.     # maximum xmlpipe2 field length, bytes  
  707.     # optional, default is 2M  
  708.     # 对于XMLLpipe2数据源允许的最大的域大小  
  709.     # max_xmlpipe2_field    = 4M  
  710.   
  711.   
  712.     # write buffer size, bytes  
  713.     # several (currently up to 4) buffers will be allocated  
  714.     # write buffers are allocated in addition to mem_limit  
  715.     # optional, default is 1M  
  716.     # 写缓冲区的大小,单位是字节。可选选项,默认值是1MB。   
  717.     # write_buffer        = 1M  
  718.   
  719.   
  720.     # maximum file field adaptive buffer size  
  721.     # optional, default is 8M, minimum is 1M  
  722.     #  
  723.     # max_file_field_buffer    = 32M  
  724. }  
  725.   
  726. #############################################################################  
  727. ## searchd settings  
  728. #############################################################################  
  729.   
  730. searchd  
  731. {  
  732.     # [hostname:]port[:protocol], or /unix/socket/path to listen on  
  733.     # known protocols are 'sphinx' (SphinxAPI) and 'mysql41' (SphinxQL)  
  734.     #  
  735.     # multi-value, multiple listen points are allowed  
  736.     # optional, defaults are 9312:sphinx and 9306:mysql41, as below  
  737.     #  
  738.     # listen            = 127.0.0.1  
  739.     # listen            = 192.168.0.1:9312  
  740.     # listen            = 9312  
  741.     # listen            = /var/run/searchd.sock  
  742.     listen            = 9312  
  743.     #listen            = 9306:mysql41  
  744.   
  745.     # log file, searchd run info is logged here  
  746.     # optional, default is 'searchd.log'  
  747.     # 全部searchd运行时事件会被记录在这个日志文件中。   
  748.     log            = /usr/local/sphinx/var/log/searchd.log  
  749.   
  750.     # query log file, all search queries are logged here  
  751.     # optional, default is empty (do not log queries)  
  752.     # 全部搜索查询会被记录在此文件中。  
  753.     query_log        = /usr/local/sphinx/var/log/query.log  
  754.   
  755.     # client read timeout, seconds  
  756.     # optional, default is 5  
  757.     #网络客户端请求的读超时时间,单位是秒。  
  758.     read_timeout        = 5  
  759.   
  760.     # request timeout, seconds  
  761.     # optional, default is 5 minutes  
  762.     #在使用持久连接时,两次查询之间等待的最长时间(单位是秒)。  
  763.     client_timeout        = 300  
  764.   
  765.     # maximum amount of children to fork (concurrent searches to run)  
  766.     # optional, default is 0 (unlimited)  
  767.     #子进程的最大数量 ,用来控制服务器负载。任何时候不可能有比此设置值更多的搜索同时运行。当达到限制时,新的输入客户端会被用临时失败(SEARCH_RETRY)状态码驳回,同时给出一个声明服务器已到最大连接限制的消息。   
  768.     max_children        = 30  
  769.   
  770.     # PID file, searchd process ID file name  
  771.     # mandatory  
  772.     #进程ID文件  
  773.     pid_file        = /usr/local/sphinx/var/log/searchd.pid  
  774.   
  775.     # max amount of matches the daemon ever keeps in RAM, per-index  
  776.     # WARNING, THERE'S ALSO PER-QUERY LIMIT, SEE SetLimits() API CALL  
  777.     # default is 1000 (just like Google)  
  778.     #守护进程在内存中为每个索引所保持并返回给客户端的匹配数目的最大值。  
  779.     max_matches        = 1000  
  780.   
  781.     # seamless rotate, prevents rotate stalls if precaching huge datasets  
  782.     # optional, default is 1  
  783.     #防止 searchd 轮换在需要预取大量数据的索引时停止响应。可选选项,默认为1(启用无缝(seamless)轮换)。   
  784.     seamless_rotate        = 1  
  785.   
  786.     # whether to forcibly preopen all indexes on startup  
  787.     # optional, default is 1 (preopen everything)  
  788.     #是否在启动是强制重新打开所有索引文件。可选选项,默认为0(不重新打开)。  
  789.     preopen_indexes        = 1  
  790.   
  791.     # whether to unlink .old index copies on succesful rotation.  
  792.     # optional, default is 1 (do unlink)  
  793.     #索引轮换成功之后,是否删除以.old为扩展名的索引拷贝。可选选项,默认为1(删除这些索引拷贝)。   
  794.     unlink_old        = 1  
  795.   
  796.     # attribute updates periodic flush timeout, seconds  
  797.     # updates will be automatically dumped to disk this frequently  
  798.     # optional, default is 0 (disable periodic flush)  
  799.     # UpdateAttributes() 调用时候更新是否隔一段时间写入磁盘  
  800.     # attr_flush_period    = 900  
  801.   
  802.   
  803.     # instance-wide ondisk_dict defaults (per-index value take precedence)  
  804.     # optional, default is 0 (precache all dictionaries in RAM)  
  805.     #对 ondisk_dict 指令的全局的默认值。 可选选项,默认值是0(将字典预先缓冲到内存)。  
  806.     # ondisk_dict_default    = 1  
  807.   
  808.   
  809.     # MVA updates pool size  
  810.     # shared between all instances of searchd, disables attr flushes!  
  811.     # optional, default size is 1M  
  812.     #网络通讯时允许的最大的包的大小。  
  813.     mva_updates_pool    = 1M  
  814.   
  815.     # max allowed network packet size  
  816.     # limits both query packets from clients, and responses from agents  
  817.     # optional, default size is 8M  
  818.     #用于多值属性MVA更新的存储空间的共享池大小。  
  819.     max_packet_size        = 8M  
  820.   
  821.     # crash log path  
  822.     # searchd will (try to) log crashed query to 'crash_log_path.PID' file  
  823.     # optional, default is empty (do not create crash logs)  
  824.     #崩溃日志文件的路径  
  825.     # crash_log_path        = /usr/local/sphinx/var/log/crash  
  826.   
  827.   
  828.     # max allowed per-query filter count  
  829.     # optional, default is 256  
  830.     #每次查询允许设置的过滤器的最大个数。只用于内部检查,不直接影响内存使用或性能。  
  831.     max_filters        = 256  
  832.   
  833.     # max allowed per-filter values count  
  834.     # optional, default is 4096  
  835.     #单个过滤器允许的值的最大个数。只用于内部检查,不直接影响内存使用或性能。  
  836.     max_filter_values    = 4096  
  837.   
  838.   
  839.     # socket listen queue length  
  840.     # optional, default is 5  
  841.     #TCP监听积压列表长度。无法如对的请求立即失败并收到“连接被拒”错误信息  
  842.     # listen_backlog        = 5  
  843.   
  844.   
  845.     # per-keyword read buffer size  
  846.     # optional, default is 256K  
  847.     #每个关键字的读缓冲区的大小。可选选项,默认值是256K。   
  848.     # read_buffer        = 256K  
  849.   
  850.   
  851.     # unhinted read size (currently used when reading hits)  
  852.     # optional, default is 32K  
  853.     #无提示时读操作的大小。可选选项,默认值是32K。  
  854.     # read_unhinted        = 32K  
  855.   
  856.   
  857.     # max allowed per-batch query count (aka multi-query count)  
  858.     # optional, default is 32  
  859.     #限制每批次的查询量。一个OPEN之后的查询量  
  860.     max_batch_queries    = 32  
  861.   
  862.   
  863.     # max common subtree document cache size, per-query  
  864.     # optional, default is 0 (disable subtree optimization)  
  865.     #  
  866.     # subtree_docs_cache    = 4M  
  867.   
  868.   
  869.     # max common subtree hit cache size, per-query  
  870.     # optional, default is 0 (disable subtree optimization)  
  871.     # 限制RAM使用一个共同的子树优化 默认不优化  
  872.     # subtree_hits_cache    = 8M  
  873.   
  874.   
  875.     # multi-processing mode (MPM)  
  876.     # known values are none, fork, prefork, and threads  
  877.     # optional, default is fork  
  878.     # 工作方式   
  879.     workers            = threads # for RT to work  
  880.   
  881.   
  882.     # max threads to create for searching local parts of a distributed index  
  883.     # optional, default is 0, which means disable multi-threaded searching  
  884.     # should work with all MPMs (ie. does NOT require workers=threads)  
  885.     #    
  886.     # dist_threads        = 4  
  887.   
  888.   
  889.     # binlog files path; use empty string to disable binlog  
  890.     # optional, default is build-time configured data directory  
  891.     # 二进制日志路径  
  892.     # binlog_path        = # disable logging  
  893.     # binlog_path        = /usr/local/sphinx/var/data # binlog.001 etc will be created there  
  894.   
  895.   
  896.     # binlog flush/sync mode  
  897.     # 0 means flush and sync every second  
  898.     # 1 means flush and sync every transaction  
  899.     # 2 means flush every transaction, sync every second  
  900.     # optional, default is 2  
  901.     # 日志刷新模式  
  902.     # binlog_flush        = 2  
  903.   
  904.   
  905.     # binlog per-file size limit  
  906.     # optional, default is 128M, 0 means no limit  
  907.     #最大日志大小  
  908.     # binlog_max_log_size    = 256M  
  909.   
  910.   
  911.     # per-thread stack size, only affects workers=threads mode  
  912.     # optional, default is 64K  
  913.     #每个线程的堆栈大小。  
  914.     # thread_stack            = 128K  
  915.   
  916.   
  917.     # per-keyword expansion limit (for dict=keywords prefix searches)  
  918.     # optional, default is 0 (no limit)  
  919.     # 扩大为一个关键字的最大数目  
  920.     # expansion_limit        = 1000  
  921.   
  922.   
  923.     # RT RAM chunks flush period  
  924.     # optional, default is 0 (no periodic flush)  
  925.     #RT索引在内存中检查的时间  
  926.     # rt_flush_period        = 900  
  927.   
  928.   
  929.     # query log file format  
  930.     # optional, known values are plain and sphinxql, default is plain  
  931.     # 查询日志格式  
  932.     # query_log_format        = sphinxql  
  933.   
  934.   
  935.     # version string returned to MySQL network protocol clients  
  936.     # optional, default is empty (use Sphinx version)  
  937.     # MYSQL版本  
  938.     # mysql_version_string    = 5.0.37  
  939.   
  940.   
  941.     # trusted plugin directory  
  942.     # optional, default is empty (disable UDFs)  
  943.     # 插件目录  
  944.     # plugin_dir            = /usr/local/sphinx/lib  
  945.   
  946.   
  947.     # default server-wide collation  
  948.     # optional, default is libc_ci  
  949.     # 链接字符集  
  950.     # collation_server        = utf8_general_ci  
  951.   
  952.   
  953.     # server-wide locale for libc based collations  
  954.     # optional, default is C  
  955.     # collation 选项  
  956.     # collation_libc_locale    = ru_RU.UTF-8  
  957.   
  958.   
  959.     # threaded server watchdog (only used in workers=threads mode)  
  960.     # optional, values are 0 and 1, default is 1 (watchdog on)  
  961.     # 是否启用服务器监控进程  
  962.     # watchdog                = 1  
  963.   
  964.       
  965.     # SphinxQL compatibility mode (legacy columns and their names)  
  966.     # optional, default is 0 (SQL compliant syntax and result sets)  
  967.     #sphinxql 兼容模式  
  968.     # compat_sphinxql_magics    = 1  
  969. }  
  970.   
  971. # --eof--  

 

建立索引:
/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf index1
不停服务下索引:
/usr/local/sphinx/bin/indexer --config /usr/local/sphinx/etc/sphinx.conf --all --rotate
启动索引服务,使PHP的客户端可用
/usr/local/sphinx/bin/searchd --config /usr/local/sphinx/etc/sphinx.conf 
建立PHP测试文件

<?php      $s = new SphinxClient;      setServer("localhost", 9312);      $s->setMatchMode(SPH_MATCH_ANY);      $s->setMaxQueryTime(3);      $result = $s->query("test");#查询      print_r ($result); ?>
运行即可

searchd 命令:

强行停止:

searchd --config /home/myuser/sphinx.conf –stop

 

安静停止:

searchd --config /home/myuser/sphinx.conf –stopwait

 

状态:

 

searchd --config /home/myuser/sphinx.conf –status

 

指定PID文件

searchd --config /home/myuser/sphinx.conf --pidfile /home/myuser/sphinx.pid

 

启动的为控制台模式:

searchd --config /home/myuser/sphinx.conf –console

 

只启动指定索引

searchd --index myindex

 

生成一些字典的工具软件:spelldump

indextool 一些转移等工具的软件

搜索字符串规则:

 

* operator OR:
hello | world

* operator NOT:
hello -world
hello !world

* field search operator:
@title hello @body world

* field position limit modifier (introduced in version 0.9.9-rc1):
@body[50] hello

* multiple-field search operator:
@(title,body) hello world

* all-field search operator:
@* hello

* phrase search operator:
"hello world"

* proximity search operator:
"hello world"~10

* quorum matching operator:
"the world is a wonderful place"/3

* strict order operator (aka operator "before"):
aaa << bbb << ccc

* exact form modifier (introduced in version 0.9.9-rc1):
raining =cats and =dogs

* field-start and field-end modifier (introduced in version 0.9.9-rc2):
^hello world$

* NEAR, generalized proximity operator (introduced in version
 2.0.1-beta):
hello NEAR/3 world NEAR/4 "my test"

* SENTENCE operator (introduced in version 2.0.1-beta):
all SENTENCE words SENTENCE "in one sentence"

* PARAGRAPH operator (introduced in version 2.0.1-beta):
"Bill Gates" PARAGRAPH "Steve Jobs"

* zone limit operator:
ZONE:(h3,h4) only in these titles

 

表达式,支持函数等 日期用的是时间戳 (好像不是作为MYSQL存储引擎的时候用不到)

* Arithmetic operators: +, -, *, /, %, DIV, MOD
* Comparison operators: <, > <=, >=, =, <>
* Boolean operators: AND, OR, NOT
* Bitwise operators: &, |
* ABS()
* BIGINT()
* CEIL()
* COS()
* CRC32()
* DAY()
* EXP()
* FLOOR()
* GEODIST()
* IDIV()
* IF()
* IN()
* INTERVAL()
* LN()
* LOG10()
* LOG2()
* MAX()
* MIN()
* MONTH()
* NOW()
* POW()
* SIN()
* SINT()
* SQRT()
* YEAR()
* YEARMONTH()
* YEARMONTHDAY()
    1. <?php   
    2.   
    3. include_once 'sphinxapi.php';  
    4. $s = new SphinxClient();  
    5. $s->setServer("localhost", 9312);  
    6. $s->SetConnectTimeout ( 1 );//设置链接超时  
    7.   
    8.   
    9. /* 
    10. $s->AddQuery();//列表查询 
    11. $s->RunQueries ();//执行列表查询 
    12. $s->ResetFilters();//清除过滤条件 
    13. $s->BuildExcerpts($docs, $index, $words);//生成简要 
    14. $s->BuildKeywords($query, $index, $hits);//生成关键字 
    15. $s->GetLastError();//错误 
    16. $s->GetLastWarning();//警告 
    17. $s->FlushAttributes();//索引刷入硬盘 
    18. $s->IsConnectError();//链接错误 
    19. $s->ResetGroupBy();//重设分组 
    20.  
    21. $s->SetFieldWeights(array('sub_title'=>1));//加权最小为1 
    22. $s->SetIDRange($min, $max);//ID范围 
    23. $s->SetIndexWeights(array('test1'=>1));//索引权重 
    24. $s->Status();//服务是否可用 
    25. $s->UpdateAttributes($index, $attrs, $values);//更新硬盘索引 
    26. */  
    27. /* 
    28. 参考文档:http://www.coreseek.cn/docs/coreseek_4.1-sphinx_2.0.1-beta.html#matching-modes 
    29. SPH_MATCH_ALL, matches all query words (default mode); 
    30. SPH_MATCH_ANY, matches any of the query words; 
    31. SPH_MATCH_PHRASE, matches query as a phrase, requiring perfect match; 
    32. SPH_MATCH_BOOLEAN, matches query as a boolean expression (see Section 5.2, “Boolean query syntax”); 
    33. SPH_MATCH_EXTENDED, matches query as an expression in Sphinx internal query language (see Section 5.3, “Extended query syntax”). As of 0.9.9, this has been superceded by SPH_MATCH_EXTENDED2, providing additional functionality and better performance. The ident is retained for legacy application code that will continue to be compatible once Sphinx and its components, including the API, are upgraded. 
    34. SPH_MATCH_EXTENDED2, matches query using the second version of the Extended matching mode. 
    35. SPH_MATCH_FULLSCAN, m 
    36. */  
    37. $s->setMatchMode(SPH_MATCH_ANY);//匹配模式  
    38. $s->setMaxQueryTime(3);//查询超时  
    39. //$s->SetSelect ( $select );//设置返回的字段  
    40. /* 
    41. $cl->SetSelect ( "*, @weight+(user_karma+ln(pageviews))*0.1 AS myweight" ); 
    42. $cl->SetSelect ( "exp_years, salary_gbp*{$gbp_usd_rate} AS salary_usd, 
    43.    IF(age>40,1,0) AS over40" ); 
    44. $cl->SetSelect ( "*, AVG(price) AS avgprice" ); 
    45.  */  
    46.   
    47. /* 
    48. $cl->SetGroupBy ( "category", SPH_GROUPBY_ATTR, "@count desc" ); 
    49. $cl->SetGroupDistinct ( "vendor" ); 
    50. == 
    51. SELECT id, weight, all-attributes, 
    52.     COUNT(DISTINCT vendor) AS @distinct, 
    53.     COUNT(*) AS @count 
    54. FROM products 
    55. GROUP BY category 
    56. ORDER BY @count DESC 
    57. */  
    58. //$s->SetGroupBy ( $groupby, SPH_GROUPBY_ATTR, $groupsort );//汇总  
    59. //$s->SetGroupDistinct ( $distinct );//设置不重复字段  
    60.   
    61. $s->SetArrayResult ( true );//结果是否有ID  
    62.   
    63. /* 
    64.     SPH_SORT_RELEVANCE mode, that sorts by relevance in descending order (best matches first); 
    65.     SPH_SORT_ATTR_DESC mode, that sorts by an attribute in descending order (bigger attribute values first); 
    66.     SPH_SORT_ATTR_ASC mode, that sorts by an attribute in ascending order (smaller attribute values first); 
    67.     SPH_SORT_TIME_SEGMENTS mode, that sorts by time segments (last hour/day/week/month) in descending order, and then by relevance in descending order; 
    68.     SPH_SORT_EXTENDED mode, that sorts by SQL-like combination of columns in ASC/DESC order; 
    69.     SPH_SORT_EXPR mode, that sorts by an arithmetic expression. 
    70.  */  
    71. //$s->SetSortMode ( SPH_SORT_EXTENDED, $sortby );//排序模式  
    72.   
    73. /* 
    74. $s->SetOverride($attrname, $attrtype, $values); 
    75. $s->ResetOverrides();*/  
    76. /* 
    77. $s->SetRetries($count);//设置失败重试 
    78. $s->SetRankingMode($ranker);//设置排名模式 均适用于SPH_MATCH_EXTENDED2搜索 
    79.  
    80. //第3个参数当为true时,相当于$attribute!=$value,默认值是false 
    81. $s->SetFilter ( 'target_type', $filtervals );//设置过滤,值列表 
    82. $s->SetFilterFloatRange($attribute, $min, $max);//浮动范围 
    83. $s->SetFilterRange($attribute, $min, $max);//指定范围 
    84. $s->SetGeoAnchor($attrlat, $attrlong, $lat, $long); 
    85. */  
    86. //link  
    87. //$s->SetFilter ( 'target_type', array(1),true );  
    88.   
    89.   
    90. $s->SetLimits ( 0, 10 );//显示数量:开始 量 最大量 右偏移量  
    91. $result = $s->query("good","team");//查询  
    92.   
    93.   
    94. print_r($result); 

posted on 2015-11-28 20:44  hahahahahai12  阅读(201)  评论(0)    收藏  举报

导航