Check if fts index has been created

Hello,

we have a couple of test system that we recreate after a build. To use fts we have to manually call ftsManager.reindexAll() (e.g. via jmx) to create the fts-index. My idea is to do this when the application starts using a AppContext.Listener:


class FtsAppContextlistener implements AppContext.Listener {

    void applicationStarted() {
        authentication.begin();

        try {
            if (!doesIndexExist())){
                ftsManager.reindexAll()
            }
        } finally {
            authentication.end();
        }
    }

    void doesIndexExist() {
      // TODO
    }
}

My problem is that I don’t know how to determine if the index does already exist (). I don’t want delete an exisiting index, but I would like to make sure the index is created after the application started.

Thanks for your help.

Yours,
Joerg

Hi Joerg,
Sorry for being obvious, but what about trying to search something via FtsService.search()?
You could also analyze the contents of the directory pointed by the fts.indexDir application property, but I think it is less reliable.

Hi Konstantin,

thanks for the answer. Sure this would be an obvious solution. I tried this and it seems to work:


    @Override
    void applicationStarted() {
        authentication.begin()

        try {
            if (ftsManager.enabled &&
                    ftsService.search('*', ['sec$User']).getEntriesCount('sec$User') == 0){
                ftsManager.reindexAll()
            }
        } finally {
            authentication.end()
        }
    }