Skip to main content

DocumentNote values can (apparently) not be queried on using API

Comments

11 comments

  • Informatiemanagement

    I'm sorry ... I finally figured it out myself. Thanks.

    0
  • Informatiemanagement

    Actually not, I discovered a mistake in the query, but the problem persists, and I mentioned it in another post: now the query DOES sometimes find the previously imported documents, but sometimes not. It seems like if I execute the action in quick succession, the documents have not been indexed yet.

    I really need a way to force Geneious to index the documents. Is there an API for that?

    0
  • Richard Moir

    I believe indexing is normally triggered immediately so you don't need to force it as such. Instead you should wait for indexing to finish using:

    WritableDatabaseService.waitForSearchIndexingToComplete()

    (on your target database)

    0
  • Informatiemanagement

    The point is waitForSearchIndexing returns immediately without doing anything for shared databases (according to the javadocs) precisely because indexing is triggered immediately.

    However, if that is so, indexing apparently takes quite some time, certainly enough time for the user to initiate another document operation before the indexing completed.

    So then I would need an API like "isStillIndexing". Only after that returns false I would let the document operation allow to do any search

    0
  • Richard Moir

    The javadoc wording is a bit misleading sorry.

    "The shared database always indexes documents immediately, so this this method always returns immediately without doing anything"

    Indexing isn't run in a separate thread in the shared database, it's synchronous, so the document doesn't even appear in the database until indexing is complete. That's what it means by it "indexes documents immediately".

    So if you are getting documents that don't show up in shared database search results then something else is going wrong (or the javadoc is wrong). Can you confirm if that's case before we dig deeper?

    0
  • Informatiemanagement

    Yes, I can confirm this. If something would be wrong with my code, I would predicatably get wrong results. But this is not the case.

     

    If I import an annotated (say) fasta document in one operation, and then in the next one search for it using the value of one of the document notes, the document sometimes comes back and sometimes not. If I wait more than about 50 seconds, the document is basically guaranteerd to come back. If I do both operations in quick succession the document most of the time does not come back, even with a call to waitForSearchIndexingToComplete.

    0
  • Informatiemanagement

    Could it be that I make the call to waitForSearchIndexingToComplete within a SwingWorker thread laucnhed from the DocumentOperation subclass, rather than in the DocumentOperation subclass itself?

    Also I make the call at the beginning of the DocumentOperation, not at the end. I don't mind users to continuing straight afterwards, but I do mind if they start the next DocumentOperation while indexing is still going on.

    0
  • Informatiemanagement

    Hello Richard,

     

    Have you had a chance to look into my problem?

     

    I have now also tried making the call to waitForSearchIndexingToComplete outside the SwingWorker thread. But even if I made it the first (or last) statement in the performOperation method, I still had the same problem.

    0
  • Richard Moir

    Sorry, I've had a chat to the dev team and it turns out we changed the behaviour a while back such that it doesn't index documents straight away, and instead does it in a background thread as you suspected.

    Unfortunately the javadoc and implementation for the waitForSearchIndexingToComplete() method have not been updated to accommodate for this.

    So there is currently no way to reliably wait for the documents to be indexed in the shared database. I have logged a bug for this but I can't provide an estimate on when it will be fixed.

    I've been trying to think of a good workaround but I haven't been able to come up with anything I'm afraid. With that knowledge, maybe you'll have more luck?

    0
  • Informatiemanagement

    Hi Richard,

     

    OK, thanks. I sure hope your dev team will pick this up quickly, because it is rather critical for us (since obviously documents can now enter the database in a functionally corrupt state - .e.g. the document version note not set correctly).

     

    I guess what I'll do now is to force users to wait for a fixed amount of seconds before allowing them to initiate another operation

    0
  • Informatiemanagement

    BTW I did in the end figure out a (pretty dirty) way od making sure has completed. After I have finished a DocumentOperarion creating or updating some DocumentNotes, I create a "ping document" with a unique value for one of our DocumentNotes. Then, while sleeping every 3 seconds, I try to retrieve that document use that value. If I get it back I take it that indexing of the other documents is now also complete, and delete the pingd ocument.

    0

Please sign in to leave a comment.