From d5ebf5a985794e6195676cd961ea410021da8f2e Mon Sep 17 00:00:00 2001 From: iaom Date: Tue, 19 Oct 2021 09:40:57 +0800 Subject: [PATCH] Fix:Term pos error when creat Xapian document. --- libsearch/index/construct-document.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/libsearch/index/construct-document.cpp b/libsearch/index/construct-document.cpp index 1b1f4eb..956d2f4 100644 --- a/libsearch/index/construct-document.cpp +++ b/libsearch/index/construct-document.cpp @@ -69,14 +69,13 @@ void ConstructDocumentForPath::run() { /* QStringList temp; // temp.append(index_text); temp.append(pinyin_text_list)*/; - int postingCount = 0; - while(postingCount < index_text.size()) { -// QVector p; -// p.append(postingCount); - doc.addPosting(QUrl::toPercentEncoding(index_text.at(postingCount)).toStdString(), postingCount); - ++postingCount; - } int i = 0; + int postingCount = 1; //terms post of Xapian document is start from 1! + while(postingCount < index_text.size()) { + doc.addPosting(QUrl::toPercentEncoding(index_text.at(i)).toStdString(), postingCount); + ++postingCount; + ++i; + } for(QString& s : pinyin_text_list) { i = 0; while(i < s.size()) {