ouwind
2009-Sep-09 05:54 UTC
[Xapian-discuss] how can i search and add document at same time
when i add bacth of documents into flint database. i want the search is valid for user. so what can i do? now my solution is to get a copy. when i add document(from the code begin_transaction to commit_transaction), i need search in the copy. does there other better way 2009-9-9 ouwind
David P. Novakovic
2009-Sep-09 05:56 UTC
[Xapian-discuss] how can i search and add document at same time
I think you want to call flush() on the db object after inserting the document. David On Wed, Sep 9, 2009 at 3:54 PM, ouwind <ouwind at 163.com> wrote:> when i add bacth of documents into flint database. i want the search is > valid for user. so what can i do? now my solution is to get a copy. when i > add document(from the code begin_transaction to commit_transaction), i need > search in the copy. does there other better way > > > 2009-9-9 > > > > ouwind > _______________________________________________ > Xapian-discuss mailing list > Xapian-discuss at lists.xapian.org > http://lists.xapian.org/mailman/listinfo/xapian-discuss >
David P. Novakovic
2009-Sep-09 06:06 UTC
[Xapian-discuss] how can i search and add document at same time
I've had this problem too - it's when the index files are at different revisions and you try to read. The only way i got around this was by creating a delta and manually (using a script that replaced old docs or added new ones) periodically merged the delta into the main index. I know sphinx offers this functionality natively which is kinda cool. I guess we could also use a lock on reads for those split moments where the files are at different revisions... On Wed, Sep 9, 2009 at 4:03 PM, ouwind <ouwind at 163.com> wrote:> i know use flush to insert a document. but how can i search document when > i call add_document and bettween. i mean not the document i am adding but > the document already existed in database. for when i add_document, it will > write database, so when i search database at this time, it will corrupt > > 2009-9-9 > ------------------------------ > ouwind > > ------------------------------ > > > > > I think you want to call flush() on the db object after inserting the > document. > > David > > On Wed, Sep 9, 2009 at 3:54 PM, ouwind <ouwind at 163.com> wrote: > >> when i add bacth of documents into flint database. i want the search is >> valid for user. so what can i do? now my solution is to get a copy. when i >> add document(from the code begin_transaction to commit_transaction), i need >> search in the copy. does there other better way >> >> >> 2009-9-9 >> >> >> >> ouwind >> _______________________________________________ >> Xapian-discuss mailing list >> Xapian-discuss at lists.xapian.org >> http://lists.xapian.org/mailman/listinfo/xapian-discuss >> > >
ouwind
2009-Sep-09 06:12 UTC
[Xapian-discuss] how can i search and add document at same time
i know use flush to insert a document. but how can i search document when i call add_document and bettween. i mean not the document i am adding but the document already existed in database. for when i add_document, it will write database, so when i search database at this time, it will corrupt 2009-9-9 ouwind I think you want to call flush() on the db object after inserting the document. David On Wed, Sep 9, 2009 at 3:54 PM, ouwind <ouwind at 163.com> wrote: when i add bacth of documents into flint database. i want the search is valid for user. so what can i do? now my solution is to get a copy. when i add document(from the code begin_transaction to commit_transaction), i need search in the copy. does there other better way 2009-9-9 ouwind _______________________________________________ Xapian-discuss mailing list Xapian-discuss at lists.xapian.org http://lists.xapian.org/mailman/listinfo/xapian-discuss
ouwind
2009-Sep-09 09:06 UTC
[Xapian-discuss] how can i search and add document at same time
sorry. i mean i has two threads, one thread is adding document to the xapian database. another threads is searching the database.both use m_indexdb.(Xapian::WritableDatabase* m_indexdb;). so it will have exception ------------------ ouwind 2009-9-9 On Wed, Sep 09, 2009 at 02:12:18PM +0800, ouwind wrote:> i know use flush to insert a document. but how can i search document > when i call add_document and bettween. i mean not the document i am > adding but the document already existed in database. for when i > add_document, it will write database, so when i search database at > this time, it will corruptIf I understand what you're asking, then you want: * to search the database for documents previous to the one you've just added, from the process adding documents (the index process) I don't know what you mean by "it will corrupt"; it certainly shouldn't corrupt the database in any way if you do this (if it does, then it's a bug). However if you simply mean that it may include the document just added, then you could avoid this by composing your query using OP_AND_NOT with a second query, which is a unique term identifying the document just added (or if more than one, a query OP_OR over the unique terms). If you're following the omega term prefix convention, you'll probably have a unique term starting with 'Q'. (If you are using the term prefix convention but aren't generating unique terms, then it's probably a good idea to start now, because it turns out very helpful in a lot of cases.) J -- James Aylett talktorex.co.uk - xapian.org - uncertaintydivision.org _______________________________________________ Xapian-discuss mailing list Xapian-discuss at lists.xapian.org http://lists.xapian.org/mailman/listinfo/xapian-discuss