How to Rebuild Virtuoso Full Text Index

Why

The Virtuoso RDF Quad store supports optional Full Text indexing of RDF object values, providing optimal querying of object values when compared to the SPARQL regex feature, which is very inefficient in most cases. In some cases, the Full Text index may need to be recreated, if unexpected results are returned when using the bif:contains Full Text index search function in SPARQL queries.

How

Note: Always ensure a full backup of the database is in in place before running these commands, such that recovery back to the current state is always possible.

The Full Text index can be recreated as follows:

  1. Drop the table and its indexes:
    drop table DB.DBA.VTLOG_DB_DBA_RDF_OBJ; 
    drop table DB.DBA.RDF_OBJ_RO_FLAGS_WORDS; 
    
  2. Recreate the index with the commands:
    DB.DBA.vt_create_text_index ( 
       fix_identifier_case ('DB.DBA.RDF_OBJ'), 
       fix_identifier_case ('RO_FLAGS'), 
       fix_identifier_case ('RO_ID'), 
       0, 0, vector (), 1, '*ini*', 'UTF-8-QR'); 
    
    DB.DBA.vt_batch_update (fix_identifier_case ('DB.DBA.RDF_OBJ'), 'ON', 1); 
    
  3. Then refill the index with command:
    DB.DBA.RDF_OBJ_FT_RECOVER(); 
    

Once complete the Virtuoso database MUST be restarted for the index rebuild to take effect.

Related