sphinx

# 1
### 添加到/usr/local/coreseek/etc/csft.conf配置文件
### 需要修改连接的数据库配置 ###
### 需要确认dict的路径配置 ###

source djapp_tag
{
type = pgsql
sql_host = 127.0.0.1
sql_user = postgres
sql_pass = *
sql_db = *
sql_port = 5190

sql_query_pre = SET NAMES 'UTF8'
sql_query_pre = update sph_counter set max_doc_id=(select max(id) from taggit_tag) where id=11
sql_query_pre = update sph_counter set max_doc_id=(select max(id) from taggit_tag) where id=12
sql_query_post =

sql_query_range = SELECT MIN(id),MAX(id) FROM taggit_tag where id<=( SELECT max_doc_id FROM sph_counter WHERE id=11 )
sql_range_step = 10000
sql_query = SELECT id, name, slug from taggit_tag WHERE id>=$start AND id<=$end

}

source daily_djapp:djapp_tag
{
sql_query_pre = SET NAMES 'UTF8'
sql_query_range = SELECT MIN(id),MAX(id) FROM taggit_tag where id>=( SELECT max_doc_id FROM sph_counter WHERE id=11 )
sql_range_step = 10000
sql_query = SELECT id, name, slug from taggit_tag WHERE id>=$start AND id<=$end
sql_query_post_index = update sph_counter set max_doc_id=$maxid where id=11
sql_query_post_index = update sph_counter set max_doc_id=$maxid where id=12
}

source delta_djapp:djapp_tag
{
sql_query_pre = SET NAMES 'UTF8'
sql_query_range = SELECT MIN(id),MAX(id) FROM taggit_tag where id>=( SELECT max_doc_id FROM sph_counter WHERE id=12 )
sql_range_step = 10000
sql_query = SELECT id, name, slug from taggit_tag WHERE id>=$start AND id<=$end
sql_query_post_index = update sph_counter set max_doc_id=$maxid where id=12
}

index djapp_tag
{
source = djapp_tag
path = /usr/local/coreseek/var/data/djapp_tag
docinfo = extern
mlock = 0
morphology = none
stopwords =
min_word_len = 1
html_strip = 0
charset_type = zh_cn.utf-8
charset_dictpath = /usr/local/coreseek/bin/etc/dict
#charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
min_prefix_len = 0
min_infix_len = 1
ngram_len = 1

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 daily_djapp:djapp_tag
{
source = daily_djapp
path = /usr/local/coreseek/var/data/daily_djapp
}

index delta_djapp:djapp_tag
{
source = delta_djapp
path = /usr/local/coreseek/var/data/delta_djapp
}


# 2
### 修改以下配置文件,添加 ###
vi /usr/local/coreseek/bin/sphinx-delta.sh
/usr/local/coreseek/bin/indexer delta_djapp --rotate -c /usr/local/coreseek/etc/csft.conf
/usr/local/coreseek/bin/indexer --merge daily_djapp delta_djapp --rotate -c /usr/local/coreseek/etc/csft.conf

vi /usr/local/coreseek/bin/sphinx-daily.sh
/usr/local/coreseek/bin/indexer daily_djapp --rotate -c /usr/local/coreseek/etc/csft.conf
/usr/local/coreseek/bin/indexer --merge djapp_tag daily_djapp --rotate -c /usr/local/coreseek/etc/csft.conf

vi /usr/local/coreseek/bin/sphinx-main.sh
/usr/local/coreseek/bin/indexer djapp_tag --rotate -c /usr/local/coreseek/etc/csft.conf


# 3
### counter 表创建 ###
CREATE TABLE sph_counter(id bigint NOT NULL, max_doc_id bigint NOT NULL, PRIMARY KEY (id));

INSERT INTO sph_counter(id, max_doc_id) VALUES(1, 0);
INSERT INTO sph_counter(id, max_doc_id) VALUES(2, 0);
INSERT INTO sph_counter(id, max_doc_id) VALUES(11, 0);
INSERT INTO sph_counter(id, max_doc_id) VALUES(12, 0);

### 初始化配置 ###
/usr/local/coreseek/bin/searchd

/usr/local/coreseek/bin/indexer --all --rotate

### 当index不存在时可以参考以下命令 ###
/usr/local/coreseek/bin/indexer djapp_tag
/usr/local/coreseek/bin/indexer delta_djapp
/usr/local/coreseek/bin/indexer daily_djapp


# 4
### create tag data for test ###


# 5
/usr/local/coreseek/bin/search -i [index] [search string]


# 6
### 替换sphinx server ip ###
vi /ebs_data/opt/typhoonae/parts/appsengine/t3rdlibs/djangosphinx/models.py
SPHINX_SERVER           = getattr(settings, 'SPHINX_SERVER', 'localhost')


# 7
### 测试 ###

## 7.1
http://192.168.10.147:8080/search

## 7.2
http://192.168.10.147:8080/tests?app=relation

### 确保使用的是t3rdlibs目录下的taggit模块 ###


# 8
### sphinx, tag, invitation 自检 ###
cd /ebs_data/opt/typhoonae/parts/appsengine/tests/simulator
python console.py -m group_share -t send_invitation
python console.py -m user_profile -t self_tag_list
python console.py -m user_profile -t search_tag
python console.py -m user_profile -t self_obj_list_by_tag


# 9
### 发布 ###
vi
self.backend_engine = "http://*:8080"

你可能感兴趣的:(python,coreseek)