[Xapian-discuss] Setting self-defined doc ID with PHP bindings

James Aylett james-xapian at tartarus.org
Fri Feb 8 23:22:00 GMT 2008


On Fri, Feb 08, 2008 at 12:16:55PM -0500, Yannick Warnier wrote:

> > It shouldn't do, no. You'll start getting issues if you need to move
> > to multiple databases, or something else more complex, but for now you
> > should be fine.
> 
> Just what I thought. Am I likely to be moving to multiple databases?
> What kind of amount of documents are we talking about to feel the need
> for additional databases (I'm plugging that into a PostgreSQL database)?
> Or are we just talking of some specific case where I would need multiple
> databases to start with?

That's difficult to answer. I wouldn't worry about it for the moment.

> I'm afraid replace_document() doesn't seem to work as it should.
> I'm logging my call to 		
> 
> $db->replace_document($myid,$doc);
> 
> $myid is equal to 19. $doc is my document. The call effectively creates
> a new document in my Xapian database, however the ID reported by a
> subsequent call to $db->get_lastdocid() equals 3, which is effectively
> the total number of documents in my database... Any idea why it would
> behave like that?

One possibility occurs: if $myid a string rather than numeric? If not,
do you have a unique term you can query the database with to find the
document and verify that it has indeed been given docid 3?

> Is there a way to go through all the database documents one at a time?
> Some kind of $db->get_firstdocid() and then $db->get_nextdocid() ?

No, sorry.

> > Try $mset->get_docid().
> 
> Is there a way to get one document's ID? (like $doc->get_id() for
> example).

You can't get a document id back from a document, because of the way
Xapian works (documents don't actually know or to an extent care where
they came from). However you can get a document id back from the mset,
as I suggested. Does this not work for you?

J

-- 
/--------------------------------------------------------------------------\
  James Aylett                                                  xapian.org
  james at tartarus.org                               uncertaintydivision.org



More information about the Xapian-discuss mailing list