"Help" PHP + Sphinx configuration can not be used! return empty! SPHINX.CONF is configured correctly

Source: Internet
Author: User
This post was last edited by default7 on 2013-09-09 12:48:15

Sphinx Configuration

Use Sphinx, and do not know if the installation was successful. However, the result is that the PHP program does not search for any content.
1) Sphinx installation directory: F:\sphinx\, configuration file: F:\sphinx\sphinx.conf
2) Database: Tbdb.ratedat,sphinx from Sphinx-for-chinese-2.1.0-dev-r3361-win32.zip
3) apache/2.4.4 (WIN32) php/5.4.16, server version: 5.6.12-log-mysql Community server (GPL)


F:\sphinx\sphinx.conf Full Content
SOURCE srcdb{type= mysqlsql_host= localhostsql_user= rootsql_pass= zbphp.com~ $sql _db= tbdbsql_port= 3306sql_query_pre   = Set NAMES utf8#sql_query_pre   = set SESSION query_cache_type=off #很奇怪, add this sentence will be an error! sql_query= \    SELECT trade_id,trade_time,goods_title,goods_price,uid_buy,uid_sell \ from    ratedatsql_attr_ bigint= trade_idsql_attr_bigint= uid_buysql_attr_bigint= uid_sellsql_attr_timestamp= trade_timesql_query_info= SELECT * from Ratedat WHERE trade_id= $id}index goods_title{    Source  =   srcdb    path    =   f:/sphinx/ Data/ratedat.goods_title    Charset_type    =   utf-8    html_strip      = 1}indexer{mem_limit= 128M} searchd{listen= 9312listen= 9306:mysql41log= f:/sphinx/log/searchd.logquery_log= F:/sphinx/log/query.logread_ timeout= 5max_children= 30pid_file= f:/sphinx/log/searchd.pidmax_matches= 1000seamless_rotate= 1preopen_indexes= 1unlink_old= 1workers= Threads # for RT to Workbinlog_path= F:/sphinx/data}



installation files F:/sphinx/install.bat
net stop SPHINXSEARCHSC Delete sphinxsearchdel/s/q%cd%\log\*.*del/s/q%cd%\data\*.*%cd%\bin\searchd--install-- Config%cd%\sphinx.conf--servicename sphinxsearch%cd%\bin\indexer-c%cd%\sphinx.conf--allnet start Sphinxsearchpause



BAT script installation process tips:
F:\sphinx>net Stop Sphinxsearchsphinxsearch service is stopping: The Sphinxsearch service has stopped successfully. F:\SPHINX>SC Delete Sphinxsearch[sc] deleteservice successf:\sphinx>del/s/q f:\sphinx\log\*.* deleting Files-F:\sphinx\ Log\query.log deleting files-f:\sphinx\log\searchd.logf:\sphinx>del/s/q f:\sphinx\data\*.* deleting files-F:\sphinx\data\ binlog.001 Delete file-F:\sphinx\data\binlog.meta Delete file-F:\sphinx\data\ratedat.goods_title.spa Delete file-F:\sphinx\data\ RATEDAT.GOODS_TITLE.SPD Deleting files-F:\sphinx\data\ratedat.goods_title.spe deleting files-F:\sphinx\data\ratedat.goods_ TITLE.SPH Delete file-F:\sphinx\data\ratedat.goods_title.spi Delete file-F:\sphinx\data\ratedat.goods_title.spk Delete file-F:\sphinx\ DATA\RATEDAT.GOODS_TITLE.SPM Deleting files-F:\sphinx\data\ratedat.goods_title.spp deleting files-F:\sphinx\data\ratedat.goods_ Title.spsf:\sphinx>f:\sphinx\bin\searchd--install--config F:\sphinx\sphinx.conf--servicename Sphinxsearchsphinx-for-chinese 2.1.0-dev (r3361) Copyright (c) 2008-2012, sphinx-search.cominstalling service ... Service ' Sphinxsearch ' installed succesfully. F:\sphInx>f:\sphinx\bin\indexer-c F:\sphinx\sphinx.conf--allsphinx-for-chinese 2.1.0-dev (r3361) Copyright (c) 2008-2012, sphinx-search.comusing config file ' F:\sphinx\sphinx.conf ' ... indexing index ' goods_title ' ... Warning:attribute ' trade_id ' not found-ignoringwarning:source srcdb:skipped 10378355 document (s) with Docid_max Idsco llected 176464 Docs, 12.1 mbsorted 0.7 mhits, 100.0% donetotal 176464 docs, 12144715 bytestotal 37.745 sec, 321754 bytes/s EC, 4675.12 Docs/sectotal 2 reads, 0.007 sec, 4604.6 kb/call avg, 3.9 msec/call Avgtotal writes, 0.360 sec, 950.7 kb/ca ll avg, 18.9 msec/call avgf:\sphinx>net start Sphinxsearchsphinxsearch service is starting. The Sphinxsearch service has started successfully. F:\sphinx>pause Please press any key to continue ...




PHP File Contents:
 Setserver (' localhost '); $rst = $s->query (' computer ');p Rint_r ($s);p rint_r ($rst);/*sphinxclient Object ([_host] =        localhost [_port] = 9312 [_offset] + 0 [_limit] = [_mode] = 0 [_weights] = = Array        () [_sort] = 0 [_sortby] = [_min_id] = 0 [_max_id] + 0 [_filters] + = Array      () [_groupby] = [_groupfunc] = 0 [_groupsort] = @group desc [_groupdistinct] = [_maxmatches] = [_cutoff] = 0 [_retrycount] = 0 [_retrydelay] + 0 [_anchor] = Ar Ray () [_indexweights] = = Array () [_ranker] + 0 [_rankexpr] = [_max Querytime] = 0 [_fieldweights] + array () [_overrides] = Array () [_sel ECT] = [_error] = [_warning] = [_connerror] = [_reqs] = = Array () [_ MBENC] = [_arrayresult] = [_timeout] = 0 [_path] = [_socket] = =) Array ([ERROR] = [WARNING] = [statu    S] = 0 [Fields] = = Array ([0] = = goods_title [1] = Goods_price)        [Attrs] = = Array ([trade_time] = 2 [Uid_buy] = 6 [Uid_sell] = 6 ) [Total] = 0 [Total_found] = 0 [TIME] = 0.000) */


Sphinx Log Content: F:\sphinx\log\query.log
[Mon Sep  9 12:40:43.311] 0.035 sec [All/0/rel 0 (0,20)] [*] pc [Mon Sep  9 12:40:48.751] 0.000 sec [all/0/ Rel 0 (0,20)] [*] Computer





Reply to discussion (solution)

Now, it looks like I should finally install the Sphinx installation successfully.
But I found that if I removed the notes below, there would be no result. Why?
There are a few questions, the search for the keyword, exactly is the number of fields targeted?
Sphinx doesn't seem to be able to specify a search in a field?? How do I specify to search within a few fields?

F:\sphinx\sphinx.conf

SOURCE srcdb{type= mysqlsql_host= localhostsql_user= rootsql_pass= zbphp.com~sql_db= tbdbsql_port= 3306sql_query_pre   = SET NAMES utf8sql_query= \    SELECT trade_id,trade_time,goods_title,goods_price,uid_buy,uid_sell,rate_txt \ from    ratedat#sql_attr_uint= trade_id #sql_attr_timestamp  = trade_time#sql_attr_float      = goods_price#sql_attr_string     = Rate_txtsql_ attr_uint= uid_buysql_attr_string     = goods_titlesql_query_info= SELECT * from Ratedat WHERE trade_id= $id}







SELECT trade_id,trade_time,goods_title,goods_price,uid_buy,uid_sell,rate_txt \
From Ratedat

It's obvious that the field has been specified. He'll search trade_id,trade_time,goods_title,goods_price,uid_buy,uid_sell,rate_txt.
These several fields

Which of these comments did you drop? I don't understand.

Which of these comments did you drop? I don't understand.

#1楼代码中的这几个注释后可以查询到:

    #sql_attr_uint        = trade_id     #sql_attr_timestamp  = trade_time    #sql_attr_float      = Goods_price    #sql_attr_string     = Rate_txt


Which of these comments did you drop? I don't understand.

#1楼代码中的这几个注释后可以查询到:

    #sql_attr_uint        = trade_id     #sql_attr_timestamp  = trade_time    #sql_attr_float      = Goods_price    #sql_attr_string     = rate_txt


The properties supported by Sphinx are as follows:
unsigned integer (1-32-bit width)
UNIX Timestamp (timestamps)
Floating-point value (32-bit, IEEE 754 single-precision)
String narration (especially the computed integer value);
Multi-valued attribute MVA (multi-value attributes)

#sql_attr_uint = trade_id
#sql_attr_string = Rate_txt
There's no such setting, it'll be an error.



Which of these comments did you drop? I don't understand.

#1楼代码中的这几个注释后可以查询到:

    #sql_attr_uint        = trade_id     #sql_attr_timestamp  = trade_time    #sql_attr_float      = Goods_price    #sql_attr_string     = Rate_txt


The properties supported by Sphinx are as follows:
unsigned integer (1-32-bit width)
UNIX Timestamp (timestamps)
Floating-point value (32-bit, IEEE 754 single-precision)
String narration (especially the computed integer value);
Multi-valued attribute MVA (multi-value attributes)

#sql_attr_uint = trade_id
#sql_attr_string = Rate_txt
There's no such setting, it'll be an error.

I find that the sql_attr_uint,sql_attr_string in the Soure section is displayed in the $rst[matches][xxxx][attr] of the search results, and if these fields are not defined in souce, Then the search return data is not accompanied by these field contents. I wrote it to get the data, but after I found it, I ran an error or no return value.









SELECT trade_id,trade_time,goods_title,goods_price,uid_buy,uid_sell,rate_txt \
From Ratedat

It's obvious that the field has been specified. He'll search trade_id,trade_time,goods_title,goods_price,uid_buy,uid_sell,rate_txt.
These several fields

But if I typed in a literal string keyword, wouldn't he also retrieve Trade_id,trade_time,uid_buy,uid_sell's content? I see this writing on the Web, specifying a search for a field with the following code:

 Setmatchmode (SPH_MATCH_EXTENDED2);    $rst = $s->query (' @goods_title '. $kw);    Print_r ($rst);    Print_r ($s);    Exit ();/*sphinxclient Object ([_host] = localhost [_port] = 9312 [_offset] + 0 [_limit] = 20    [_mode] = 6 [_weights] = Array () [_sort] = 0 [_sortby] = [_min_id] + 0 [_max_id] = 0 [_filters] = Array () [_groupby] = [_groupfunc] + 0 [_GROUPSO     RT] = @group desc [_groupdistinct] = [_maxmatches] = [_cutoff] + 0 [_retrycount] = 0 [_retrydelay] = 0 [_anchor] = Array () [_indexweights] = = Array () [ _ranker] + 0 [_rankexpr] = [_maxquerytime] = 0 [_fieldweights] = = Array () [_ov  Errides] + Array () [_select] = * [_error] = query error:no field ' Goods_title ' found in  schema [_warning] =   [_connerror] = [_reqs] = = Array () [_mbenc] = [_arrayresult] = [_timeout] = 0 [_path] = [_socket] = *


Tip: [_error] = + query error:no field ' Goods_title ' found in schema
But if I remove the "@goods_title" to search for results, sphinx How can I specify search results in a text string

Now the contents of my entire configuration file are as follows, file f:/sphinx/sphinx.conf

SOURCE db{type= mysqlsql_host= localhostsql_user= rootsql_pass= zbphp.com~ $sql _db= zbphp_comsql_port= 3306sql_query_ Pre = SET NAMES utf8}source buyer:db{sql_query = \ SELECT trade_id,trade_time,goods_price,goods_title,uid_b       Uy,uid_sell,rate_txt \ from Ratedat sql_attr_uint = uid_buysql_attr_string = Goods_titlesql_attr_float = Goods_pricesql_attr_timestamp = Trade_time sql_query_info= SELECT * from Ratedat WHERE trade_id= $id}index Buye rlist{type = Plain Source = Buyer Path = f:/sphinx/data/buyerlist DocInfo = extern ml Ock = 0 Morphology = None stopwords = Min_word_len = 1 Charset_type = utf-8 html _strip = 1 Min_prefix_len = 0 Min_infix_len = 1 Ngram_len = 1 charset_table = u+ff10. u+ff19->0..9, 0..9, u+ff41. U+ff5a->a. Z, U+FF21. U+ff3a->a. Z,\ A.. Z->a. Z, A.. Z, u+0149, u+017f, u+0138, U+00DF, U+00FF, u+00c0. u+00d6->u+00e0..u+00f6,\ u+00e0. U+00f6, U+00d8. U+00de->u+00f8. U+00fe, U+00f8. U+00fe, u+0100->u+0101, u+0101,\ u+0102->u+0103, u+0103, u+0104->u+0105, u+0105, U+0106->U+0107, U+0107, U+ 0108->u+0109,\ u+0109, u+010a->u+010b, u+010b, u+010c->u+010d, u+010d, u+010e->u+010f, U+010F,\ U+0110-& Gt u+0111, u+0111, u+0112->u+0113, u+0113, u+0114->u+0115, u+0115, \ u+0116->u+0117,u+0117, U+0118->U+0119, U+ 0119, u+011a->u+011b, u+011b, u+011c->u+011d,\ u+011d,u+011e->u+011f, u+011f, U+0130->U+0131, U+0131, U+01 32->u+0133, u+0133, \ u+0134->u+0135,u+0135, u+0136->u+0137, u+0137, u+0139->u+013a, U+013A, U+013B->U+ 013C, \ u+013c,u+013d->u+013e, u+013e, u+013f->u+0140, u+0140, u+0141->u+0142, u+0142, \ U+0143->U+0144, u+0144, u+0145->u+0146, u+0146, u+0147->u+0148, u+0148, u+014a->u+014b, \ u+014b,u+014c->u+014d, U+014D, U+ 014e->u+014f, u+014f, u+0150->u+0151, u+0151, \ u+0152->u+0153,u+0153, u+0154->u+0155, u+0155, u+0156->u+0157, u+0157, u+0158->u+0159,\ U+0159,U+015A->U+015B, U+ 015B, u+015c->u+015d, u+015d, u+015e->u+015f, u+015f, \ u+0160->u+0161,u+0161, u+0162->u+0163, U+0163, U+01 64->u+0165, u+0165, u+0166->u+0167, \ u+0167,u+0168->u+0169, u+0169, u+016a->u+016b, U+016B, U+016C->U+    016D, u+016d, \ u+016e->u+016f,u+016f, u+0170->u+0171, u+0171, u+0172->u+0173, u+0173, U+0174->U+0175,\ u+0175,u+0176->u+0177, u+0177, u+0178->u+00ff, u+00ff, u+0179->u+017a, u+017a, \ U+017B->U+017C,U+017C, U+ 017d->u+017e, u+017e, u+0410..u+042f->u+0430..u+044f, \ u+0430..u+044f,u+05d0. U+05ea, u+0531..u+0556->u+0561..u+0586, u+0561..u+0587, \ u+0621..u+063a, U+01B9,U+01BF, U+0640..U+064A, U+0660..U +0669, u+066e, u+066f, \ u+0671..u+06d3, u+06f0. u+06ff,u+0904..u+0939, u+0958..u+095f, u+0960..u+0963, \ u+0966..u+096f, u+097b. U+097F,U+0985..U+09B9, U+09ce, U+09DC. U+09e3, U+09e6.. U+09ef, \ u+0a05. U+0a39, U+0a59. U+0a5e,u+0a66. u+0a6f, U+0a85. U+0AB9, U+0ae0. U+0ae3, \ U+0ae6. U+0AEF, U+0b05. u+0b39,u+0b5c. U+0b61, u+0b66. u+0b6f, U+0b71, u+0b85. U+0BB9, \ U+0be6. U+0BF2, U+0C05. U+0c39,u+0c66. u+0c6f, u+0c85. U+0CB9, U+0CDE. U+0ce3, \ U+0ce6. U+0CEF, u+0d05. U+0d39, U+0d60,u+0d61, U+0d66. u+0d6f, u+0d85. U+0DC6, \ u+1900..u+1938, u+1946..u+194f, u+a800. u+a805,u+a807. u+a822, u+0386->u+03b1, \ u+03ac->u+03b1, u+0388->u+03b5, U+03ad->u+03b5,u+0389->u+03b7, U+03AE->U +03b7, \ u+038a->u+03b9, U+0390->U+03B9, u+03aa->u+03b9,u+03af->u+03b9, u+03ca->u+03b9, \ U+038C-> U+03BF, U+03CC->U+03BF, u+038e->u+03c5,u+03ab->u+03c5, u+03b0->u+03c5, \ U+03CB->U+03C5, U+03CD->U +03C5, u+038f->u+03c9,u+03ce->u+03c9, u+03c2->u+03c3, \ u+0391..u+03a1->u+03b1. U+03c1,u+03a3. U+03a9->u+03c3. U+03C9, u+03b1. U+03C1, \ u+03c3. U+03C9, U+0e01. U+0e2e,u+0e30. U+0E3A, U+0e40. U+0e45, U+0e47, U+0e50. U+0e59, \ u+a000. u+a48f, u+4e00. U+9FBF,U+3400..U+4DBF, U+20000..U+2A6DF, u+f900. U+faff, \ u+2f800. U+2FA1F, U+2e80. U+2eff,u+2f00. U+2FDF, u+3100..u+312f, u+31a0. U+31BF, \ u+3040..u+309f, u+30a0. U+30ff,u+31f0. U+31FF, u+ac00. U+D7AF, u+1100..u+11ff, \ u+3130..u+318f, u+a000. u+a48f,u+a490. U+A4CF ngram_chars = u+4e00. U+9FBF, U+3400..U+4DBF, U+20000..U+2A6DF, u+f900. U+faff,\ u+2f800. U+2FA1F, U+2e80. U+2eff, u+2f00. U+2FDF, u+3100..u+312f, u+31a0. U+31bf,\ u+3040..u+309f, u+30a0. U+30FF, u+31f0. U+31FF, u+ac00. U+D7AF, u+1100..u+11ff,\ u+3130..u+318f, u+a000. u+a48f, u+a490.  U+a4cf}index rt{type = RT Path = F:/sphinx/data/rt Rt_field = goods_title Rt_field = Rate_txt rt_attr_uint = uid_buy}indexer{mem_limit= 128m}searchd{listen= 9312listen= 9306:mysql41log = F:/sphinx/log/searchd.logquer y_log= f:/sphinx/log/query.logread_timeout = 5max_children = 30pid_file= f:/sphinx/log/searchd.pidmax_matches= 1000s Eamless_rotate = 1preopen_indexes = 1unlink_old= 1workers= threadsbinlog_path= F:/sphinx/data} 




1) inside the index RT {} I do not know how to use, not type = MySQL, why the index RT this type=rt? If you do not add the index RT This paragraph can also be installed successfully
2) The installation of this sphinx.conf is successful, but as in the previous building, you specify to search in a field "@goods_title $kw" returned error error is query error:no field ' goods_title ' found In schema.
3) How can I realize the cross-table query? What I want to get is this data, three tables Ratedat,rate_buyer,userdat:

SELECT A.*,b.*,c.nick from Rate_buyer a left joins Ratedat B on A.uid=b.uid_buyleft joins Userdat C on A.uid=c.uid WHERE 1GR OUP by A.uid ORDER by B.costsum DESC LIMIT $startnum, $perpage;


I wrote this in sphinx.conf, the installation succeeded, but only one result at a time:
SOURCE buyer:db{    sql_query = \        SELECT a.uid,a.costsum,a.costmax,a.costmin,a.costavg,a.costcount \        , B.goods_price,b.goods_title,b.trade_id,b.trade_time,b.uid_buy \        , C.nick \ from        rate_buyer a \ Left        JOIN Ratedat b on a.uid=b.uid_buy \ Left        joins Userdat C on a.uid=c.uid \        GROUP by a.uid \        ORDER by a.costsum DESC \    sql_attr_uint       = uid_buysql_attr_string     = goods_titlesql_attr_float      = goods_pricesql_attr_ Timestamp  = trade_time    sql_query_info= SELECT * from Ratedat WHERE trade_id= $id}



Installation process bat prompt record:
Sphinxsearch Service is stopping: The Sphinxsearch service has stopped successfully. [SC] DeleteService Success Delete file-F:\sphinx\data\binlog.meta Delete file-F:\sphinx\data\rt.kill Delete file-F:\sphinx\data\rt.lock Delete file- F:\sphinx\data\rt.meta Delete file-F:\sphinx\data\rt.ramsphinx-for-chinese 2.1.0-dev (r3361) Copyright (c) 2008-2012, Sphinx-search.cominstalling service ... Service ' Sphinxsearch ' installed Succesfully.sphinx-for-chinese 2.1.0-dev (r3361) Copyright (c) 2008-2012, sphinx-search.comusing config file ' F:\sphinx\sphinx.conf ' ... indexing index ' buyerlist ' ... collected 136 docs, 0.0 mbsorted 0.0 mhits, 100.0% donetotal 136 docs, 6577 bytestotal 0.305 sec, 21558 bytes/sec, 445.78 docs/secskipping Non-pla In index ' RT ' ... total 2 reads, 0.000 sec, 145.0 kb/call avg, 0.0 msec/call Avgtotal writes, 0.028 sec, 61.5 kb/call avg , 2.8 msec/call Avgsphinx-for-chinese 2.1.0-dev (r3361) Copyright (c) 2008-2012, sphinx-search.comusing config file ' F:\sp Hinx\sphinx.conf ' ... index ' buyerlist ': Query ' iPhone ': returned 0 matches of 0 total in 0.000 SECWORds:1. ' iphone ': 0 documents, 0 hitsindex ' RT ': Search error:failed to open f:/sphinx/data/rt.sph:no such file ordirectory. The Sphinxsearch service is starting. The Sphinxsearch service has started successfully. Please press any key to continue ...
  • 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.