34 #include <string_view>
42 #define MAGIC_XOR_VALUE 96
47 if (last_term.empty())
return;
49 if (last_synonyms.empty()) {
54 for (
auto&& synonym : last_synonyms) {
60 last_synonyms.clear();
68 if (last_term !=
term) {
73 if (get_exact_entry(
term, tag)) {
74 const char*
p = tag.data();
75 const char* end =
p + tag.size();
82 last_synonyms.insert(
string(
p, len));
88 last_synonyms.emplace(synonym);
94 if (last_term !=
term) {
99 if (get_exact_entry(
term, tag)) {
100 const char*
p = tag.data();
101 const char* end =
p + tag.size();
108 last_synonyms.emplace(
p, len);
114 #ifdef __cpp_lib_associative_heterogeneous_erasure
115 last_synonyms.erase(synonym);
117 last_synonyms.erase(
string(synonym));
129 if (last_term ==
term) {
130 last_synonyms.clear();
140 vector<string> synonyms;
142 if (last_term ==
term) {
143 if (last_synonyms.empty())
return NULL;
145 synonyms.reserve(last_synonyms.size());
146 for (
auto&& i : last_synonyms) {
147 synonyms.push_back(i);
151 if (!get_exact_entry(
term, tag))
return NULL;
153 const char*
p = tag.data();
154 const char* end =
p + tag.size();
161 synonyms.push_back(
string(
p, len));
182 return database->synonym_table.get_approx_entry_count();
196 if (cursor->after_end()) {
198 if (cursor->find_entry_ge(prefix))
203 if (cursor->after_end() || !
startswith(cursor->current_key, prefix)) {
207 current_term = cursor->current_key;
216 if (cursor->after_end() && prefix >
term) {
223 if (cursor->find_entry_ge(
term)) {
229 if (cursor->after_end() || !
startswith(cursor->current_key, prefix)) {
233 current_term = cursor->current_key;
void clear_synonyms(std::string_view term)
Remove all synonyms for term.
void add_synonym(std::string_view term, std::string_view synonym)
Add a synonym for term.
void remove_synonym(std::string_view term, std::string_view synonym)
Remove a synonym for term.
TermList * open_termlist(std::string_view term) const
Open synonym termlist for a term.
TermList * skip_to(std::string_view term)
Advance to the first term which is >= term.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
~HoneySynonymTermList()
Destructor.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
TermList * next()
Advance to the next term in the list.
This class stores a list of terms.
DatabaseCorruptError indicates database corruption was detected.
InvalidOperationError indicates the API was used in an invalid way.
Abstract base class for termlists.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
#define LOGCALL_DTOR(CATEGORY, CLASS)
Hierarchy of classes which Xapian can throw as exceptions.
Database using honey backend.
Synonym data for a honey database.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Various handy string-related helpers.
bool startswith(std::string_view s, char pfx)
A vector-like container of terms which can be iterated.