On Fri, Mar 30, 2007 at 03:27:35PM +0200, Andreas Marienborg
wrote:> I was wondering, if I have a Search::Xapian::Document object, how can
> I find it's id? or is that Very Bad?
It's not currently possible. If you want get a Document object from a
Database, you have to remember what document id it had if you want to
know.
I've wondered before if this should be possible. A Document which came
from a Database does actually know the Database and document id
internally since we fetch information lazily from the Database.
The points against I can see are:
* You can create a Document object from scratch and it then has no
document id associated (though it could just return 0 if it didn't
come from a Database).
* The document id doesn't mean much without also knowing the Database
but if you're searching over several Database objects together then
the (Database, document id) pair that the Document knows is for the
sub-Database not the combined Database, which users might find
suprising...
What are you want to know the docid for?
If it's so you can modify the document and replace it then the second
point doesn't currently apply as you can't write to a combined database.
That restriction might be lifted at some point though.
Or it might be possible to have a "Document::replace()" method.
Cheers,
Olly