Marius Tibeica
2012-Jul-09 19:41 UTC
[Xapian-devel] Question about Document and TermIterator.get_termfreq()
Hi, 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 will add code snippets if it is required. Thanks, Marius -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xapian.org/pipermail/xapian-devel/attachments/20120709/d3ecc072/attachment.html>
Olly Betts
2012-Jul-10 01:00 UTC
[Xapian-devel] Question about Document and TermIterator.get_termfreq()
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