66 LOGCALL(API,
string,
"Document::get_value", slot);
73 LOGCALL(API,
string,
"Document::get_data", NO_ARGS);
81 internal->set_data(data);
92 : internal(other.internal)
103 return internal->get_description();
110 internal->add_value(slot, value);
117 internal->remove_value(slot);
124 internal->clear_values();
132 LOGCALL_VOID(API,
"Document::add_posting", tname | tpos | wdfinc);
136 internal->add_posting(tname, tpos, wdfinc);
142 LOGCALL_VOID(API,
"Document::add_term", tname | wdfinc);
146 internal->add_term(tname, wdfinc);
153 LOGCALL_VOID(API,
"Document::remove_posting", tname | tpos | wdfdec);
157 internal->remove_posting(tname, tpos, wdfdec);
169 if (
rare(termpos_first > termpos_last)) {
172 return internal->remove_postings(term, termpos_first, termpos_last,
180 internal->remove_term(tname);
187 internal->clear_terms();
229 LOGCALL(API, std::string,
"Document::serialise", NO_ARGS);
257 LOGCALL(DB,
bool,
"OmDocumentTerm::add_position", wdf_inc | tpos);
299 vector<Xapian::termpos>::iterator i;
301 if (i ==
positions.end() || *i != tpos) {
304 if (
rare(new_split > numeric_limits<decltype(
split)>::max())) {
326 LOGCALL_VOID(DB,
"OmDocumentTerm::remove_position", tpos);
333 " not in list, can't remove");
355 if (i ==
positions.end() || *i != tpos) {
378 if (i ==
positions.end() || *i > termpos_last) {
381 auto j = upper_bound(i,
positions.end(), termpos_last);
391 description =
"OmDocumentTerm(wdf = ";
393 description +=
", positions[";
403 map<Xapian::valueno, string>::const_iterator i;
405 if (i ==
values.end())
return string();
415 LOGCALL(DB,
string,
"Xapian::Document::Internal::get_data", NO_ARGS);
416 if (data_here)
RETURN(data);
417 if (!database.get())
RETURN(
string());
431 LOGCALL(DB,
TermList *,
"Document::Internal::open_term_list", NO_ARGS);
435 if (!database.get())
RETURN(NULL);
436 RETURN(database->open_term_list(did));
443 if (!value.empty()) {
444 values[slot] = value;
456 map<Xapian::valueno, string>::iterator i = values.find(slot);
457 if (i == values.end()) {
459 " is not present in document, in "
460 "Xapian::Document::Internal::remove_value()");
477 positions_modified =
true;
479 map<string, OmDocumentTerm>::iterator i;
480 i = terms.find(tname);
481 if (i == terms.end()) {
485 terms.insert(make_pair(tname, std::move(newterm)));
487 if (i->second.add_position(wdfinc, tpos))
497 map<string, OmDocumentTerm>::iterator i;
498 i = terms.find(tname);
499 if (i == terms.end()) {
502 terms.insert(make_pair(tname, std::move(newterm)));
504 if (i->second.increase_wdf(wdfinc))
516 map<string, OmDocumentTerm>::iterator i;
517 i = terms.find(tname);
518 if (i == terms.end() || i->second.is_deleted()) {
522 "' is not present in document, in "
523 "Xapian::Document::Internal::remove_posting()");
525 i->second.remove_position(tpos);
526 if (wdfdec) i->second.decrease_wdf(wdfdec);
527 positions_modified =
true;
538 auto i = terms.find(term);
539 if (i == terms.end() || i->second.is_deleted()) {
543 "' is not present in document, in "
544 "Xapian::Document::Internal::remove_postings()");
546 auto n_removed = i->second.remove_positions(termpos_first, termpos_last);
548 positions_modified =
true;
553 wdf_delta = numeric_limits<Xapian::termcount>::max();
555 i->second.decrease_wdf(wdf_delta);
565 map<string, OmDocumentTerm>::iterator i;
566 i = terms.find(tname);
567 if (i == terms.end() || i->second.is_deleted()) {
571 "' is not present in document, in "
572 "Xapian::Document::Internal::remove_term()");
575 if (!positions_modified) {
576 positions_modified = (i->second.positionlist_count() > 0);
589 positions_modified =
true;
601 return termlist_size;
607 if (terms_here)
return;
608 if (database.get()) {
611 for ( ; t != tend; ++t) {
617 terms.insert(terms.end(), make_pair(*t, std::move(term)));
620 termlist_size = terms.size();
636 string desc =
"Document(";
646 if (data_here) desc +=
", ";
648 desc +=
str(values.size());
653 if (data_here || values_here) desc +=
", ";
655 desc +=
str(termlist_size);
659 if (database.get()) {
660 if (data_here || values_here || terms_here) desc +=
", ";
675 if (database.get()) {
677 do_get_all_values(values);
686 database->invalidate_doc_object(
this);
Iteration over values in a document.
void merge() const
Merge sorted ranges before and after split.
void append_position(Xapian::termpos termpos)
Append a position.
bool add_position(Xapian::termcount wdf_inc, Xapian::termpos termpos)
Add a position.
term_positions positions
Positional information.
void remove_position(Xapian::termpos tpos)
Remove an entry from the position list.
string get_description() const
Return a string describing this object.
bool is_deleted() const
Has this term been deleted from this document?
unsigned split
Split point in the position range.
Xapian::termpos remove_positions(Xapian::termpos termpos_first, Xapian::termpos termpos_last)
Remove a range of positions.
Xapian::termcount wdf
Within document frequency of the term.
A document in the database, possibly plus modifications.
string get_data() const
Get data stored in document.
Xapian::termcount termlist_count() const
void add_value(Xapian::valueno, const string &)
void remove_value(Xapian::valueno)
void remove_posting(const string &, Xapian::termpos, Xapian::termcount)
void add_term(const string &, Xapian::termcount)
string get_value(Xapian::valueno slot) const
Get value by value number.
void set_data(const string &)
void add_posting(const string &, Xapian::termpos, Xapian::termcount)
virtual string do_get_value(Xapian::valueno) const
string get_description() const
Return a string describing this object.
document_values values
The values associated with this document.
Xapian::termpos remove_postings(const string &, Xapian::termpos, Xapian::termpos, Xapian::termcount)
Xapian::valueno values_count() const
TermList * open_term_list() const
Open a term list.
virtual ~Internal()
Destructor.
Xapian::Internal::intrusive_ptr< const Xapian::Database::Internal > database
The database this document is in.
void remove_term(const string &)
A handle representing a document in a Xapian database.
void remove_term(const std::string &tname)
Remove a term and all postings associated with it.
void remove_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfdec=1)
Remove a posting of a term from the document.
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
void add_posting(const std::string &tname, Xapian::termpos tpos, Xapian::termcount wdfinc=1)
Add an occurrence of a term at a particular position.
std::string get_data() const
Get data stored in the document.
Xapian::termpos remove_postings(const std::string &term, Xapian::termpos term_pos_first, Xapian::termpos term_pos_last, Xapian::termcount wdf_dec=1)
Remove a range of postings for a term.
void operator=(const Document &other)
Assignment is allowed.
ValueIterator values_begin() const
Iterator for the values in this document.
docid get_docid() const
Get the document id which is associated with this document (if any).
std::string get_value(Xapian::valueno slot) const
Get value by number.
void remove_value(Xapian::valueno slot)
Remove any value with the given number.
void add_term(const std::string &tname, Xapian::termcount wdfinc=1)
Add a term to the document, without positional information.
Xapian::termcount termlist_count() const
The length of the termlist - i.e.
TermIterator termlist_begin() const
Start iterating the terms in this document.
Xapian::Internal::intrusive_ptr< Internal > internal
void clear_values()
Remove all values associated with the document.
std::string get_description() const
Return a string describing this object.
void clear_terms()
Remove all terms (and postings) from the document.
void set_data(const std::string &data)
Set data stored in the document.
static Document unserialise(const std::string &serialised)
Unserialise a document from a string produced by serialise().
std::string serialise() const
Serialise document into a string.
Document()
Make a new empty Document.
Xapian::termcount values_count() const
Count the values in this document.
InvalidArgumentError indicates an invalid parameter value was passed to the API.
Class for iterating over term positions.
Abstract base class for termlists.
Class for iterating over a list of terms.
PositionIterator positionlist_end() const
Return an end PositionIterator for the current term.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
PositionIterator positionlist_begin() const
Return a PositionIterator for the current term.
Class for iterating over document values.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
#define LOGCALL_STATIC(CATEGORY, TYPE, FUNC, PARAMS)
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
Append a string to an object description, escaping invalid UTF-8.
Iteration over values in a document.
Hierarchy of classes which Xapian can throw as exceptions.
API for working with documents.
TermList which iterates a std::map.
string str(int value)
Convert int to std::string.
The Xapian namespace contains public interfaces for the Xapian library.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
unsigned valueno
The number for a value slot in a document.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
#define AssertRel(A, REL, B)
Arithmetic operations with overflow checks.
std::enable_if< std::is_unsigned< T1 >::value &&std::is_unsigned< T2 >::value &&std::is_unsigned< R >::value, bool >::type mul_overflows(T1 a, T2 b, R &res)
Multiplication with overflow checking.
string serialise_document(const Xapian::Document &doc)
Serialise a Xapian::Document object.
Xapian::Document unserialise_document(const string &s)
Unserialise a serialised Xapian::Document object.
functions to convert classes to strings and back
Convert types to std::string.
void description_append(std::string &desc, const std::string &s)
Class for iterating over document values.