Add user rank to result query (sphinx)
This commit is contained in:
parent
685c719ec1
commit
dc8e5d35a7
@ -123,30 +123,16 @@ class SphinxSearch:
|
|||||||
good_vars_word_count = len(set([v.parent for v in good_vars]))
|
good_vars_word_count = len(set([v.parent for v in good_vars]))
|
||||||
freq_vars_word_count = len(set([v.parent for v in freq_vars]))
|
freq_vars_word_count = len(set([v.parent for v in freq_vars]))
|
||||||
|
|
||||||
|
self.__configure(sphinx_conf.index_addjobj, word_count)
|
||||||
# формируем строки для поиска в Сфинксе
|
# формируем строки для поиска в Сфинксе
|
||||||
for i in range(good_vars_word_count, max(0, good_vars_word_count - 3), -1):
|
for i in range(good_vars_word_count, max(0, good_vars_word_count - 3), -1):
|
||||||
first_q = "@fullname \"{}\"/{}".format(" ".join(good_var.text for good_var in good_vars), i)
|
first_q = "@fullname \"{}\"/{}".format(" ".join(good_var.text for good_var in good_vars), i)
|
||||||
if self.search_freq_words and freq_vars_word_count:
|
if self.search_freq_words and freq_vars_word_count:
|
||||||
second_q = " @sname {}".format(" ".join(freq_var.text for freq_var in freq_vars))
|
second_q = " @sname {}".format(" ".join(freq_var.text for freq_var in freq_vars))
|
||||||
self.client_show.AddQuery(first_q + second_q, sphinx_conf.index_addjobj)
|
self.client_show.AddQuery(first_q + second_q, sphinx_conf.index_addjobj)
|
||||||
|
|
||||||
self.client_show.AddQuery(first_q, sphinx_conf.index_addjobj)
|
self.client_show.AddQuery(first_q, sphinx_conf.index_addjobj)
|
||||||
|
|
||||||
# if self.search_freq_words:
|
|
||||||
# for j in range(freq_vars_word_count, -1, -1):
|
|
||||||
# if j == 0:
|
|
||||||
# second_q = ""
|
|
||||||
# else:
|
|
||||||
# second_q = " @sname {}".format(" | ".join(freq_var.text for freq_var in freq_vars), j)
|
|
||||||
# second_q = second_q.replace("*", "")
|
|
||||||
#
|
|
||||||
# print first_q + second_q
|
|
||||||
# self.client_show.AddQuery(first_q + second_q, sphinx_conf.index_addjobj)
|
|
||||||
# else:
|
|
||||||
# print first_q
|
|
||||||
# self.client_show.AddQuery(first_q, sphinx_conf.index_addjobj)
|
|
||||||
|
|
||||||
self.__configure(sphinx_conf.index_addjobj, word_count)
|
|
||||||
|
|
||||||
start_t = time.time()
|
start_t = time.time()
|
||||||
rs = self.client_show.RunQueries()
|
rs = self.client_show.RunQueries()
|
||||||
elapsed_t = time.time() - start_t
|
elapsed_t = time.time() - start_t
|
||||||
@ -164,9 +150,7 @@ class SphinxSearch:
|
|||||||
if not ma['attrs']['aoid'] in parsed_ids:
|
if not ma['attrs']['aoid'] in parsed_ids:
|
||||||
parsed_ids.append(ma['attrs']['aoid'])
|
parsed_ids.append(ma['attrs']['aoid'])
|
||||||
results.append(
|
results.append(
|
||||||
dict(aoid=ma['attrs']['aoid'], text=unicode(ma['attrs']['fullname']), ratio=ma['weight'],
|
dict(aoid=ma['attrs']['aoid'], text=unicode(ma['attrs']['fullname']), ratio=ma['attrs']['krank'],
|
||||||
cort=i))
|
cort=i))
|
||||||
|
|
||||||
# results.sort(key=lambda x: Levenshtein.ratio(text, x['text']), reverse=False)
|
|
||||||
|
|
||||||
return results
|
return results
|
||||||
|
@ -143,7 +143,8 @@ class SphinxHelper:
|
|||||||
out_filename = os.path.abspath(config_fname)
|
out_filename = os.path.abspath(config_fname)
|
||||||
logging.info("Creating main config %s...", out_filename)
|
logging.info("Creating main config %s...", out_filename)
|
||||||
|
|
||||||
conf_data = template('aore/templates/sphinx/sphinx.conf', sphinx_listen=sphinx_conf.listen,
|
conf_data = template('aore/templates/sphinx/sphinx.conf',
|
||||||
|
sphinx_listen=sphinx_conf.listen.replace("unix://", ''),
|
||||||
sphinx_var_path=sphinx_conf.var_dir)
|
sphinx_var_path=sphinx_conf.var_dir)
|
||||||
|
|
||||||
f = open(out_filename, "w")
|
f = open(out_filename, "w")
|
||||||
|
@ -24,6 +24,7 @@ index {{ index_name }}
|
|||||||
|
|
||||||
# strip html by default
|
# strip html by default
|
||||||
html_strip = 1
|
html_strip = 1
|
||||||
|
docinfo = extern
|
||||||
|
|
||||||
ignore_chars = @, -
|
ignore_chars = @, -
|
||||||
charset_table = 0..9, A..Z->a..z, _, a..z, \
|
charset_table = 0..9, A..Z->a..z, _, a..z, \
|
||||||
|
@ -20,5 +20,4 @@ index {{index_name}}
|
|||||||
source = {{index_name}}
|
source = {{index_name}}
|
||||||
path = {{sphinx_var_path}}/data/{{index_name}}
|
path = {{sphinx_var_path}}/data/{{index_name}}
|
||||||
docinfo = extern
|
docinfo = extern
|
||||||
charset_type = utf-8
|
|
||||||
}
|
}
|
@ -43,11 +43,6 @@ searchd
|
|||||||
# mandatory
|
# mandatory
|
||||||
pid_file = {{sphinx_var_path}}/run/searchd.pid
|
pid_file = {{sphinx_var_path}}/run/searchd.pid
|
||||||
|
|
||||||
# max amount of matches the daemon ever keeps in RAM, per-index
|
|
||||||
# WARNING, THERE'S ALSO PER-QUERY LIMIT, SEE SetLimits() API CALL
|
|
||||||
# default is 1000 (just like Google)
|
|
||||||
max_matches = 1000
|
|
||||||
|
|
||||||
# seamless rotate, prevents rotate stalls if precaching huge datasets
|
# seamless rotate, prevents rotate stalls if precaching huge datasets
|
||||||
# optional, default is 1
|
# optional, default is 1
|
||||||
seamless_rotate = 1
|
seamless_rotate = 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user