From 34e5e81e7afe240b05f2df834d21e08dbb4bcf79 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 18 Jan 2023 23:33:56 +0100 Subject: Free search: "raw" index for reference - improve parent only search --- ishtar_common/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'ishtar_common/utils.py') diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 340fb9ee0..1219dd454 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -934,6 +934,9 @@ def num2col(n): return string +RE_TSVECTOR = re.compile(r"('[^']+':\d+(?:,\d+)*)") + + def merge_tsvectors(vectors): """ Parse tsvector to merge them in one string @@ -952,16 +955,20 @@ def merge_tsvectors(vectors): if max_position > current_position: current_position = max_position - for dct_member in vector.split(" "): + for dct_member in RE_TSVECTOR.findall(vector): splitted = dct_member.split(":") key = ":".join(splitted[:-1]) - positions = splitted[-1] key = key[1:-1] # remove quotes + result_dict[key] = [1] + """ + # position is not used today - simplify + positions = splitted[-1] positions = [int(pos) + current_position for pos in positions.split(",")] if key in result_dict: result_dict[key] += positions else: result_dict[key] = positions + """ # {'lamelie': [1, 42, 5]} => {'lamelie': "1,42,5"} result_dict = { -- cgit v1.2.3