狮身人面像:"错误在/(10054,'')"

时间:2012-09-19 12:50:21

标签: django postgresql sphinx

我使用Django,posgresql,Sphinx 2.0.5

搜索功能:

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
}

我用命令

开始搜索
D:/Old/Sphinx/bin/searchd --config D:/Old/Sphinx/bin/sphinx.conf

当我启动Django并转到localhost时: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 个答案:

答案 0 :(得分:1)

 client.SetServer('127.0.0.1', 5432)

您正在尝试连接到端口5432.但是

listen          = 9312
listen          = 9306:mysql41

建议你让狮身人面像听9312端口。

您应该使用相同的端口!