1 #ifndef EPT_TEXTSEARCH_TEXTSEARCH_H
2 #define EPT_TEXTSEARCH_TEXTSEARCH_H
39 namespace textsearch {
110 static std::string
toLower(
const std::string& str);
118 void normalize_and_add(Xapian::Document& doc,
const std::string& term,
int& pos)
const;
133 const Xapian::Database&
db()
const {
return m_db; }
139 bool hasData()
const {
return m_timestamp > 0; }
155 const std::vector<const ExtraIndexer*>& extraIndexers = std::vector<const ExtraIndexer*>());
160 Xapian::docid
docidByName(
const std::string& pkgname)
const;
165 Xapian::Query
makeORQuery(
const std::string& keywords)
const;
178 template<
typename ITER>
179 Xapian::Query
makeORQuery(
const ITER& begin,
const ITER& end)
const
181 std::vector<std::string> terms;
183 for (ITER i = begin; i != end; ++i)
186 std::string s =
m_stem(t);
189 terms.push_back(
"Z" + s);
191 return Xapian::Query(Xapian::Query::OP_OR, terms.begin(), terms.end());
195 std::vector<std::string>
expand(Xapian::Enquire& enq)
const;
207 double getDoubleValue(
const std::string& pkgname, Xapian::valueno val_id)
const;
212 int getIntValue(
const std::string& pkgname, Xapian::valueno val_id)
const;
const Xapian::valueno VAL_ITERATING_RATING
Definition: textsearch.h:45
int getIntValue(const std::string &pkgname, Xapian::valueno val_id) const
Get the integer value for.
Definition: textsearch.cc:240
time_t timestamp() const
Timestamp of when the Xapian database was last updated.
Definition: textsearch.h:136
const Xapian::valueno VAL_ITERATING_SECURITY
Definition: textsearch.h:48
Xapian::Database m_db
Definition: textsearch.h:106
const Xapian::valueno VAL_ITERATING_FUNCTIONALITY
Definition: textsearch.h:46
const Xapian::valueno VAL_ITERATING_USABILITY
Definition: textsearch.h:47
const Xapian::valueno VAL_APT_PACKAGE_SIZE
Definition: textsearch.h:43
Xapian::Stem m_stem
Definition: textsearch.h:107
Xapian::Query makeORQuery(const ITER &begin, const ITER &end) const
Build a query with the given keywords, specified as iterators of strings.
Definition: textsearch.h:179
const Xapian::valueno VAL_ITERATING_QUALITY
Definition: textsearch.h:50
const Xapian::Database & db() const
Access the Xapian database.
Definition: textsearch.h:133
const Xapian::valueno VAL_ITERATING_PERFORMANCE
Definition: textsearch.h:49
-*- C++ -*- (c) 2006, 2007 Petr Rockai me@mornfall.net
Definition: apt.cc:43
RecordParser specialised with access methods for common Debian package information.
Definition: packagerecord.h:36
double getDoubleValue(const std::string &pkgname, Xapian::valueno val_id) const
Get the integer value for.
Definition: textsearch.cc:227
Xapian::Query makePartialORQuery(const std::string &keywords) const
Tokenize the string and build an OR query with the resulting keywords.
Definition: textsearch.cc:153
bool rebuildIfNeeded(apt::Apt &apt, const std::vector< const ExtraIndexer * > &extraIndexers=std::vector< const ExtraIndexer * >())
Rebuild the index if needed.
Definition: textsearch.cc:81
std::vector< std::string > expand(Xapian::Enquire &enq) const
Return a list of tag-based terms that can be used to expand an OR query.
Definition: textsearch.cc:197
const Xapian::valueno VAL_ITERATING_ADOPTION
Definition: textsearch.h:52
High-level access to the Apt cache, as a data provider for the ept framework.
Definition: apt/apt.h:60
Xapian::Query makeORQuery(const std::string &keywords) const
Tokenize the string and build an OR query with the resulting keywords.
Definition: textsearch.cc:147
static std::string toLower(const std::string &str)
Return a lowercased copy of the string.
Definition: textsearch.cc:58
bool hasData() const
Returns true if the index has data.
Definition: textsearch.h:139
Xapian::Query makeRelatedQuery(const std::string &pkgname) const
Create a query to look for packages similar to the given one.
Definition: textsearch.cc:212
Maintains and accesses a Xapian index of package descriptions.
Definition: textsearch.h:102
Xapian::docid docidByName(const std::string &pkgname) const
Retrieve a Xapian docid by package name.
Definition: textsearch.cc:181
const Xapian::valueno VAL_POPCON
Definition: textsearch.h:44
time_t m_timestamp
Definition: textsearch.h:105
const Xapian::valueno VAL_ITERATING_SUPPORT
Definition: textsearch.h:51
Xapian::Database & db()
Access the Xapian database.
Definition: textsearch.h:130
void normalize_and_add(Xapian::Document &doc, const std::string &term, int &pos) const
Add normalised tokens computed from the string to the document doc.
Definition: textsearch.cc:72
const Xapian::valueno VAL_APT_INSTALLED_SIZE
Definition: textsearch.h:42
TextSearch()
Definition: textsearch.cc:50
bool needsRebuild(apt::Apt &apt)
Returns true if the index is older than the Apt database information.
Definition: textsearch.cc:67