mu-document: fix phrase-queries, small o10ns

Fix the phrase-query term-generator

Avoid double utf8_flatten
This commit is contained in:
Dirk-Jan C. Binnema
2026-07-23 11:45:22 +03:00
committed by Seth Ladygo
parent f9ad65423e
commit 877b946539
2 changed files with 114 additions and 19 deletions

View File

@ -1,4 +1,4 @@
/** Copyright (C) 2022-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
/** Copyright (C) 2022-2026 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
**
** 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
@ -165,7 +165,10 @@ public:
*
* @return message s-expression string
*/
std::string sexp_str() const { return xdoc_.get_data(); }
std::string sexp_str() const {
/* xapian_document() flushes any dirty cached sexp first */
return xapian_document().get_data();
}
/**
* Generically adds an optional value, if set, to the document
@ -242,6 +245,7 @@ public:
private:
template<typename SexpType> void sexp_put_prop(const Field& field, SexpType&& val);
void sexp_remove_prop(const Field& field);
void add_search_term(const Field& field, const std::string& val);
Sexp& cached_sexp() const {
if (cached_sexp_.empty())
@ -251,9 +255,13 @@ private:
}
mutable Xapian::Document xdoc_;
Options options_;
mutable Sexp cached_sexp_;
Options options_;
mutable Sexp cached_sexp_;
mutable bool dirty_sexp_{}; /* xdoc's sexp is outdated */
Xapian::termcount termpos_{}; /* next index term-position;
* tracked so phrases cannot
* match across unrelated
* texts */
};
MU_ENABLE_BITOPS(Document::Options);