我使用 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, '*')
狮身人面像.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))
这个错误是什么意思,我需要做什么?