2012-09-19 146 views
0

我使用Django,posgresql,斯芬克斯2.0.5斯芬克斯: 「出錯/(10054, '')」

搜索功能:

def search(S): 
    from sphinxapi import SphinxClient, SPH_MATCH_ANY, SPH_SORT_RELEVANCE 
    client = SphinxClient() 
    client.SetServer('127.0.0.1', 5432) 
    client.SetMatchMode(SPH_MATCH_ANY) 
    client.SetSortMode(SPH_SORT_RELEVANCE) 
    client.SetFieldWeights({'header': 20, 'text': 10}) 
    result = client.Query(S, '*') 

sphinx.conf中:

source src1 
{ 
    type   = pgsql 

    sql_host  = localhost 
    sql_user  = blizzard_moz455_1_3 
    sql_pass  = <pwd> 
    sql_db   = blizzard_moz455_1_3 
    sql_port  = 5432 

    sql_query  = \ 
     SELECT id, header, text \ 
     FROM app_main 

    sql_query_info  = SELECT * FROM app_main WHERE id=$id 
} 


index test1 
{ 
    source   = src1 
    path   = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/data/test1 
    docinfo   = extern 
    charset_type  = sbcs 
} 


index testrt 
{ 
    type   = rt 
    rt_mem_limit  = 32M 

    path   = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/data/testrt 
    charset_type  = utf-8 

    rt_field  = title 
    rt_field  = content 
    rt_attr_uint  = gid 
} 


indexer 
{ 
    mem_limit  = 32M 
} 


searchd 
{ 
    listen   = 9312 
    listen   = 9306:mysql41 
    log   = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/log/searchd.log 
    query_log  = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/log/query.log 
    read_timeout  = 5 
    max_children  = 30 
    pid_file  = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/log/searchd.pid 
    max_matches  = 1000 
    seamless_rotate  = 1 
    preopen_indexes  = 1 
    unlink_old  = 1 
    workers   = threads # for RT to work 
    binlog_path  = D:/blizzard/Projects/Python/Web/moz455/app/sphinx/data 
} 

我開始用命令searchd

D:/Old/Sphinx/bin/searchd --config D:/Old/Sphinx/bin/sphinx.conf 

當我開始Dj安戈並轉到本地主機:8000頁面加載約半分鐘,然後下面的錯誤出現:

error at/
(10054, '') 

回溯:

D:\blizzard\Projects\Python\Web\venv\Lib\site-packages\django\core\handlers\base.py in get_response 
response = callback(request, *callback_args, **callback_kwargs) 

D:\blizzard\Projects\Python\Web\moz455\app\views.py in index 
search("style") 

D:\blizzard\Projects\Python\Web\moz455\app\views.py in search 
result = client.Query(S, '*') 

D:\blizzard\Projects\Python\Web\moz455\app\sphinxapi.py in Query 
results = self.RunQueries() 

D:\blizzard\Projects\Python\Web\moz455\app\sphinxapi.py in RunQueries 
sock = self._Connect() 

D:\blizzard\Projects\Python\Web\moz455\app\sphinxapi.py in _Connect 
v = unpack('>L', sock.recv(4)) 

這個錯誤是什麼手段,什麼我需要做什麼?

回答

1
client.SetServer('127.0.0.1', 5432) 

有你試圖連接到端口5432,但

listen   = 9312 
listen   = 9306:mysql41 

建議你獅身人面像偵聽端口9312.

你應該使用相同的端口!