mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-18 23:45:52 +08:00
优化sphinx
This commit is contained in:
+35
-4
@@ -114,8 +114,12 @@ def mkdirAll():
|
||||
rep = 'path\s*=\s*(.*)'
|
||||
p = re.compile(rep)
|
||||
tmp = p.findall(content)
|
||||
|
||||
for x in tmp:
|
||||
public.execShell('mkdir -p ' + x)
|
||||
if x.find('binlog') != -1:
|
||||
public.execShell('mkdir -p ' + x)
|
||||
else:
|
||||
public.execShell('mkdir -p ' + os.path.dirname(x))
|
||||
|
||||
|
||||
def initDreplace():
|
||||
@@ -146,8 +150,31 @@ def initDreplace():
|
||||
return file_bin
|
||||
|
||||
|
||||
def checkIndexSph():
|
||||
content = public.readFile(getConf())
|
||||
rep = 'path\s*=\s*(.*)'
|
||||
p = re.compile(rep)
|
||||
tmp = p.findall(content)
|
||||
for x in tmp:
|
||||
if x.find('binlog') != -1:
|
||||
continue
|
||||
else:
|
||||
p = x+'.sph'
|
||||
if os.path.exists(p):
|
||||
return False
|
||||
return True
|
||||
|
||||
def start():
|
||||
file = initDreplace()
|
||||
|
||||
data = sphinxConfParse()
|
||||
if 'index' in data :
|
||||
if checkIndexSph():
|
||||
rebuild()
|
||||
time.sleep(5)
|
||||
else:
|
||||
return '配置不正确!'
|
||||
|
||||
data = public.execShell(file + ' start')
|
||||
if data[1] == '':
|
||||
return 'ok'
|
||||
@@ -264,15 +291,15 @@ def runStatus():
|
||||
return public.returnJson(True, 'ok', rData)
|
||||
|
||||
|
||||
def sphinxCmd():
|
||||
def sphinxConfParse():
|
||||
file = getConf()
|
||||
bin_dir = getServerDir()
|
||||
content = public.readFile(file)
|
||||
rep = 'index\s(.*)'
|
||||
sindex = re.findall(rep, content)
|
||||
indexlen = len(sindex)
|
||||
cmd = {}
|
||||
if indexlen > 0:
|
||||
cmd = {}
|
||||
cmd_index = []
|
||||
cmd_delta = []
|
||||
for x in range(indexlen):
|
||||
@@ -284,8 +311,12 @@ def sphinxCmd():
|
||||
cmd['index'] = cmd_index
|
||||
cmd['delta'] = cmd_delta
|
||||
cmd['cmd'] = bin_dir + '/bin/bin/indexer -c ' + bin_dir + '/sphinx.conf'
|
||||
return cmd
|
||||
|
||||
return public.returnJson(True, 'ok', cmd)
|
||||
def sphinxCmd():
|
||||
data = sphinxConfParse()
|
||||
if 'index' in data:
|
||||
return public.returnJson(True, 'ok', data)
|
||||
else:
|
||||
return public.returnJson(False, 'no index')
|
||||
|
||||
|
||||
@@ -103,27 +103,30 @@ function runStatus(){
|
||||
|
||||
function readme(){
|
||||
spPost('sphinx_cmd', '', function(data){
|
||||
|
||||
var rdata = $.parseJSON(data.data);
|
||||
if (!rdata['status']){
|
||||
layer.msg(rdata['msg'],{icon:2,time:2000,shade: [0.3, '#000']});
|
||||
return;
|
||||
}
|
||||
|
||||
var con = '';
|
||||
var con = '<ul class="help-info-text c7">';
|
||||
|
||||
con += '<li style="color:red;">如果数据量比较大,第一次启动会失败!(可通过手动建立索引)</li>';
|
||||
//主索引
|
||||
for (var i = 0; i < rdata['data']['index'].length; i++) {
|
||||
var index_t = rdata['data']['index'][i];
|
||||
con += '<p>主索引:' + rdata['data']['cmd'] + ' '+ index_t +' --rotate </p>';
|
||||
con += '<li>主索引:' + rdata['data']['cmd'] + ' '+ index_t +' --rotate</li>';
|
||||
}
|
||||
|
||||
for (var i = 0; i < rdata['data']['delta'].length; i++) {
|
||||
var delta_t = rdata['data']['delta'][i];
|
||||
var list = delta_t.split(':');
|
||||
console.log(list);
|
||||
con += '<p>增量索引:' + rdata['data']['cmd'] + ' '+ list[0] +' --rotate </p>';
|
||||
con += '<p>合并索引:' + rdata['data']['cmd'] + ' --merge '+ list[1] + ' ' + list[0] +' --rotate </p>';
|
||||
con += '<li>增量索引:' + rdata['data']['cmd'] + ' '+ list[0] +' --rotate</li>';
|
||||
con += '<li>合并索引:' + rdata['data']['cmd'] + ' --merge '+ list[1] + ' ' + list[0] +' --rotate</li>';
|
||||
}
|
||||
con += '</ul>';
|
||||
|
||||
$(".soft-man-con").html(con);
|
||||
});
|
||||
|
||||
@@ -52,7 +52,7 @@ source search_hash
|
||||
index search_hash
|
||||
{
|
||||
source = search_hash
|
||||
path = {$SERVER_APP}/index/db/search_hash
|
||||
path = {$SERVER_APP}/index/db/search_hash/index
|
||||
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
|
||||
@@ -65,7 +65,7 @@ source search_hash_delta : search_hash
|
||||
index search_hash
|
||||
{
|
||||
source = search_hash
|
||||
path = {$SERVER_APP}/index/db/search_hash
|
||||
path = {$SERVER_APP}/index/db/search_hash/index
|
||||
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
@@ -75,7 +75,7 @@ index search_hash
|
||||
index search_hash_delta : search_hash
|
||||
{
|
||||
source = search_hash_delta
|
||||
path = {$SERVER_APP}/index/db/search_hash_delta
|
||||
path = {$SERVER_APP}/index/db/search_hash_delta/index
|
||||
|
||||
ngram_len = 1
|
||||
ngram_chars = U+3000..U+2FA1F
|
||||
|
||||
Reference in New Issue
Block a user