[Xapian-devel] Question about Document and TermIterator.get_termfreq()

Olly Betts olly at survex.com
Tue Jul 10 02:00:32 BST 2012


On Mon, Jul 09, 2012 at 10:41:46PM +0300, Marius Tibeica wrote:
> While porting the unit tests from perl for the node binding I noticed a
> test failed.
> I basically create a document, add a few terms, add the document to a
> database and then call doc->termlist_begin().get_termfreq(). This throws
> "Can't get term frequency from a document termlist which is not associated
> with a database."
> 
> What I think this means is that I can not call get_termfreq from a
> TermIterator obtained from a document (this is only available for a
> TermIterator obtained from a Database object). Am I right?

I think if you get a Document object using Database::get_document(),
then you can get the termfreq this way (but I haven't checked), but not
if you create a new Document and add it to the database.

It could probably be hooked up to work for this case, but I'm not sure
it is very useful, and it creates another reference to the Database
object so could result in existing code not closing the database when it
expects to.

Cheers,
    Olly



More information about the Xapian-devel mailing list