2021-01-29 11:43:07 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020, KylinSoft Co., Ltd.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* Authors: zhangpengfei <zhangpengfei@kylinos.cn>
|
|
|
|
*
|
|
|
|
*/
|
2020-12-30 15:31:36 +08:00
|
|
|
#ifndef DOCUMENT_H
|
|
|
|
#define DOCUMENT_H
|
|
|
|
|
|
|
|
#include <xapian.h>
|
|
|
|
#include <QString>
|
|
|
|
#include <QStringList>
|
2021-01-02 17:21:38 +08:00
|
|
|
#include <QVector>
|
2021-12-14 14:43:35 +08:00
|
|
|
namespace UkuiSearch {
|
2021-04-26 15:06:47 +08:00
|
|
|
class Document {
|
2020-12-30 15:31:36 +08:00
|
|
|
public:
|
2021-01-19 19:26:39 +08:00
|
|
|
Document() = default;
|
2021-04-26 15:06:47 +08:00
|
|
|
~Document() {}
|
|
|
|
Document(const Document& other) {
|
2021-01-19 10:44:28 +08:00
|
|
|
m_document = other.m_document;
|
2022-10-26 18:01:40 +08:00
|
|
|
m_uniqueTerm = other.m_uniqueTerm;
|
|
|
|
m_time = other.m_time;
|
2021-01-19 10:44:28 +08:00
|
|
|
}
|
2021-04-26 15:06:47 +08:00
|
|
|
void operator=(const Document& other) {
|
|
|
|
m_document = other.m_document;
|
2022-10-26 18:01:40 +08:00
|
|
|
m_uniqueTerm = other.m_uniqueTerm;
|
|
|
|
m_time = other.m_time;
|
2021-01-19 10:44:28 +08:00
|
|
|
}
|
2021-05-17 14:47:39 +08:00
|
|
|
void setData(QString &data);
|
2021-04-26 15:06:47 +08:00
|
|
|
void addPosting(std::string term, QVector<size_t> offset, int weight = 1);
|
2021-06-23 15:50:19 +08:00
|
|
|
void addPosting(std::string &term, std::vector<size_t> &offset, int weight = 1);
|
2021-04-26 15:06:47 +08:00
|
|
|
void addPosting(std::string term, unsigned int offset, int weight = 1);
|
2021-01-13 11:02:15 +08:00
|
|
|
void addTerm(QString term);
|
2021-06-23 15:50:19 +08:00
|
|
|
void addTerm(std::string term);
|
2021-11-10 10:20:16 +08:00
|
|
|
void addValue(unsigned slot, QString value);
|
2022-04-19 09:16:20 +08:00
|
|
|
void addSortableSerialiseValue(unsigned slot, QString value);
|
2020-12-30 15:31:36 +08:00
|
|
|
void setUniqueTerm(QString term);
|
2021-06-23 15:50:19 +08:00
|
|
|
void setUniqueTerm(std::string term);
|
2022-10-26 18:01:40 +08:00
|
|
|
std::string getUniqueTerm() const;
|
|
|
|
Xapian::Document getXapianDocument() const;
|
|
|
|
void setIndexTime(const QString& time);
|
|
|
|
const std::string indexTime() const;
|
|
|
|
|
2020-12-30 15:31:36 +08:00
|
|
|
private:
|
2021-01-19 10:44:28 +08:00
|
|
|
Xapian::Document m_document;
|
2022-10-26 18:01:40 +08:00
|
|
|
std::string m_uniqueTerm;
|
|
|
|
std::string m_time;
|
2020-12-30 15:31:36 +08:00
|
|
|
|
|
|
|
};
|
2021-04-30 16:28:50 +08:00
|
|
|
}
|
2020-12-30 15:31:36 +08:00
|
|
|
|
|
|
|
#endif // DOCUMENT_H
|