#include <textsearch.h>
Contrarily to Debtags and Popcon, TextSearch does not attempt to create the index in the home directory if no system index is found and it is not running as root: this is to avoid secretly building large indexes (>50Mb) in the home directory of users.
The idea then is to have root keep the index up to date, possibly running a reindexing tool once a day, or after an apt-get update.
This works because the full text search index is useful even if it is slightly out of date.
Public Member Functions | |
| TextSearch () | |
| Xapian::Database & | db () |
| Access the Xapian database. | |
| const Xapian::Database & | db () const |
| Access the Xapian database. | |
| time_t | timestamp () const |
| Timestamp of when the Xapian database was last updated. | |
| bool | hasData () const |
| Returns true if the index has data. | |
| bool | needsRebuild (apt::Apt &apt) |
| Returns true if the index is older than the Apt database information. | |
| bool | rebuildIfNeeded (apt::Apt &apt) |
| Rebuild the index if needed. | |
| bool | rebuildIfNeeded (apt::Apt &apt, const debtags::Debtags &debtags) |
| Rebuild the index if needed. | |
| Xapian::docid | docidByName (const std::string &pkgname) const |
| Retrieve a Xapian docid by package name. | |
| Xapian::Query | makeORQuery (const std::string &keywords) const |
| Tokenize the string and build an OR query with the resulting keywords. | |
| Xapian::Query | makePartialORQuery (const std::string &keywords) const |
| Tokenize the string and build an OR query with the resulting keywords. | |
| template<typename ITER> | |
| Xapian::Query | makeORQuery (const ITER &begin, const ITER &end) const |
| Build a query with the given keywords, specified as iterators of strings. | |
| 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. | |
| Xapian::Query | makeRelatedQuery (const std::string &pkgname) const |
| Create a query to look for packages similar to the given one. | |
Protected Member Functions | |
| 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. | |
Static Protected Member Functions | |
| static std::string | toLower (const std::string &str) |
| Return a lowercased copy of the string. | |
Protected Attributes | |
| time_t | m_timestamp |
| Xapian::Database | m_db |
| Xapian::Stem | m_stem |
| ept::textsearch::TextSearch::TextSearch | ( | ) |
| std::string ept::textsearch::TextSearch::toLower | ( | const std::string & | str | ) | [static, protected] |
Return a lowercased copy of the string.
| void ept::textsearch::TextSearch::normalize_and_add | ( | Xapian::Document & | doc, | |
| const std::string & | term, | |||
| int & | pos | |||
| ) | const [protected] |
Add normalised tokens computed from the string to the document doc.
pos is used as a sequence generator for entering the token position in the document.
| Xapian::Database& ept::textsearch::TextSearch::db | ( | ) | [inline] |
Access the Xapian database.
| const Xapian::Database& ept::textsearch::TextSearch::db | ( | ) | const [inline] |
Access the Xapian database.
| time_t ept::textsearch::TextSearch::timestamp | ( | ) | const [inline] |
Timestamp of when the Xapian database was last updated.
| bool ept::textsearch::TextSearch::hasData | ( | ) | const [inline] |
Returns true if the index has data.
| bool ept::textsearch::TextSearch::needsRebuild | ( | apt::Apt & | apt | ) |
Returns true if the index is older than the Apt database information.
| bool ept::textsearch::TextSearch::rebuildIfNeeded | ( | apt::Apt & | apt | ) |
Rebuild the index if needed.
| bool ept::textsearch::TextSearch::rebuildIfNeeded | ( | apt::Apt & | apt, | |
| const debtags::Debtags & | debtags | |||
| ) |
Rebuild the index if needed.
Also index tags.
| Xapian::docid ept::textsearch::TextSearch::docidByName | ( | const std::string & | pkgname | ) | const |
Retrieve a Xapian docid by package name.
| Xapian::Query ept::textsearch::TextSearch::makeORQuery | ( | const std::string & | keywords | ) | const |
Tokenize the string and build an OR query with the resulting keywords.
| Xapian::Query ept::textsearch::TextSearch::makePartialORQuery | ( | const std::string & | keywords | ) | const |
Tokenize the string and build an OR query with the resulting keywords.
The last token in keywords is considered to be typed only partially, to implement proper search-as-you-type.
| Xapian::Query ept::textsearch::TextSearch::makeORQuery | ( | const ITER & | begin, | |
| const ITER & | end | |||
| ) | const [inline] |
Build a query with the given keywords, specified as iterators of strings.
| vector< string > ept::textsearch::TextSearch::expand | ( | Xapian::Enquire & | enq | ) | const |
Return a list of tag-based terms that can be used to expand an OR query.
| Xapian::Query ept::textsearch::TextSearch::makeRelatedQuery | ( | const std::string & | pkgname | ) | const |
Create a query to look for packages similar to the given one.
time_t ept::textsearch::TextSearch::m_timestamp [protected] |
Xapian::Database ept::textsearch::TextSearch::m_db [protected] |
Xapian::Stem ept::textsearch::TextSearch::m_stem [protected] |
1.5.3