2010-05-12 2 views
0

Я создал django-sphinx в своем проекте, который отлично работает только в течение некоторого времени. Позже он всегда возвращает пустой набор результатов. Удивительно перезапустить приложение django исправляет его. И поиск работает снова, но снова только на короткое время (или очень ограниченное число запросов). Heres мой sphinx.conf:Django sphinx работает только после перезагрузки приложения

source src_questions 
{ 
    # data source 
    type  = mysql 
    sql_host = xxxxxx 
    sql_user = xxxxxx #replace with your db username 
    sql_pass = xxxxxx #replace with your db password 
    sql_db  = xxxxxx #replace with your db name 
    # these two are optional 
    sql_port = xxxxxx 
    #sql_sock = /var/lib/mysql/mysql.sock 

    # pre-query, executed before the main fetch query 
    sql_query_pre = SET NAMES utf8 

    # main document fetch query 
    sql_query  =  SELECT q.id AS id, q.title AS title, q.tagnames AS tags, q.html AS text, q.level AS level \ 
          FROM question AS q \ 
          WHERE q.deleted=0 \ 

    # optional - used by command-line search utility to display document information 
    sql_query_info = SELECT title, id, level FROM question WHERE id=$id 

    sql_attr_uint = level 
} 

index questions { 
    # which document source to index 
    source  = src_questions 

    # this is path and index file name without extension 
    # you may need to change this path or create this folder 
    path   = /home/rafal/index/index_questions 
    # docinfo (ie. per-document attribute values) storage strategy 
    docinfo  = extern 

    # morphology 
    morphology = stem_en 

    # stopwords file 
    #stopwords = /var/data/sphinx/stopwords.txt 

    # minimum word length 
    min_word_len = 3 

    # uncomment next 2 lines to allow wildcard (*) searches 
    min_infix_len = 1 
    enable_star = 1 

    # charset encoding type 
    charset_type = utf-8 
} 

# indexer settings 
indexer 
{ 
    # memory limit (default is 32M) 
    mem_limit = 64M 
} 

# searchd settings 
searchd 
{ 
    # IP address on which search daemon will bind and accept 
    # optional, default is to listen on all addresses, 
    # ie. address = 0.0.0.0 
    address  = 127.0.0.1 

    # port on which search daemon will listen 
    port  = 3312 

    # searchd run info is logged here - create or change the folder 
    log  = ../log/sphinx.log 

    # all the search queries are logged here 
    query_log = ../log/query.log 

    # client read timeout, seconds 
    read_timeout = 5 

    # maximum amount of children to fork 
    max_children = 30 

    # a file which will contain searchd process ID 
    pid_file = searchd.pid 

    # maximum amount of matches this daemon would ever retrieve 
    # from each index and serve to client 
    max_matches = 1000 
} 

и Heres мой поиск часть из views.py:

content = Question.search.query(keywords) 
    if level: 
     content = content.filter(level=level)#level is array of integers 

Там нет ошибок в любых журналах, это как раз не возвращая никаких результатов. Я установил 'indexer -rotate -all' для запуска каждые 5 минут в cron, и searchd запускается и работает все время. Вся помощь была бы очень признательна.

ответ

0

Какая версия сфинкса? Джанго-сфинкс? sphinxsearch api? питон?

В любом случае, попробуйте удалить indexer из cron &, если эта проблема не устранена. Дайте мне знать, как это происходит.

Смежные вопросы