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

Yannick Warnier ywarnier at beeznest.org
Sat Feb 9 05:03:00 GMT 2008


Le vendredi 08 février 2008 à 23:22 +0000, James Aylett a écrit :
> 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? 

Yes, that was right. I had read somewhere that it was important but I
did forgot it (I'm too used to PHP :)).

> 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?

Not really but now I send the ID as an integer it works, so it's not a
problem anymore.

> > 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?

Yes, indeed. Sorry about that, seems like I've not been reading
carefully enough.

All in all, that solves this set of problems completely. Many thanks.

Yannick




More information about the Xapian-discuss mailing list