Alessandro Pasotti
2008-Apr-24 17:25 UTC
[Xapian-discuss] how to delete all document from the DB (without deleting the DB itself)
Hello, I'm still testing PHP5 bindings and I could'nt find a way to delete all documents from a DB without deleting other informations stored in the DB such as synonyms. Since the process of adding synonyms is time consuming, I would like to use the same DB but restart my test without any document in the DB, is this possibile? I could'nt find a delete_all or a method like that, nor an iterator over all documents without querying. Any idea? -- Alessandro Pasotti w3: www.itopen.it
Rusty Conover
2008-Apr-24 17:31 UTC
[Xapian-discuss] how to delete all document from the DB (without deleting the DB itself)
On Apr 24, 2008, at 11:25 AM, Alessandro Pasotti wrote:> Hello, > > I'm still testing PHP5 bindings and I could'nt find a way to delete > all documents from a DB without deleting other informations stored in > the DB such as synonyms. > > Since the process of adding synonyms is time consuming, I would like > to use the same DB but restart my test without any document in the DB, > is this possibile? > > I could'nt find a delete_all or a method like that, nor an iterator > over all documents without querying. > > Any idea? >Hi, Why is adding synonyms a time consuming operation, it seems pretty constant time from my experience. Thanks, Rusty -- Rusty Conover InfoGears Inc. http://www.infogears.com
Richard Boulton
2008-Apr-24 18:09 UTC
[Xapian-discuss] how to delete all document from the DB (without deleting the DB itself)
Alessandro Pasotti wrote:> Hello, > > I'm still testing PHP5 bindings and I could'nt find a way to delete > all documents from a DB without deleting other informations stored in > the DB such as synonyms. > > Since the process of adding synonyms is time consuming, I would like > to use the same DB but restart my test without any document in the DB, > is this possibile? > > I could'nt find a delete_all or a method like that, nor an iterator > over all documents without querying.There isn't a delete_all() method, but there is a way to get an iterator over all the documents in the database. In C++, you simply need to use the Database::postlist_begin() method with an empty string - this will return a PostingIterator which returns all the document IDs in the database. You can then call delete document on them. This is wrapped in the normal way in the PHP bindings. For your particular case, another approach is to first add all the synonyms to a clean database, flush, and then for each test you could create your test database by make a copy of that database (using standard file copy operations to copy the database directory). -- Richard
Andreas Marienborg
2008-Apr-25 06:19 UTC
[Xapian-discuss] how to delete all document from the DB (without deleting the DB itself)
On Apr 24, 2008, at 7:25 PM, Alessandro Pasotti wrote:> Hello, > > I'm still testing PHP5 bindings and I could'nt find a way to delete > all documents from a DB without deleting other informations stored in > the DB such as synonyms. > > Since the process of adding synonyms is time consuming, I would like > to use the same DB but restart my test without any document in the DB, > is this possibile? > > I could'nt find a delete_all or a method like that, nor an iterator > over all documents without querying. > > Any idea?I would keep a DB with only synonyms and then do a copy of it (on the filesystem level) whenever I needed a clean DB to do my testruns. - andreas