Search code examples
xquerybasex

Indexes getting removed after update operation in database


I am using Basex version 8.6.6 I am creating full text indexes on database from the GUI, when any update operation is happening on the database all created indexes getting removed.

When I use ft module to search anything then error occurs that database "test" has no full text index.

I am expecting if index already created then it should not removed.

How I can resolve this issue?


Solution

  • When you update your database then index is obviously not valid anymore (if nothing is done automatically). The default behaviour of BaseX is to simply drop the index. There are several possibilities to deal with this, they are all explained in the BaseX docu at https://docs.basex.org/wiki/Indexes#Updates

    Given that you seem to use full-textr indexes you have basically two options:

    1. Call optimize after each updating operation, either by XQuery db:optimize() or via the BaseX command OPTIMIZE
    2. Enable incremental indexes. For this you will have to set UPINDEX and AUTOOPTIMIZE both to true.

    Please be aware that the second option can be very costly if you have many small changes and a large database as it will re-create the whole index after each small update.