How to Rebuild Virtuoso Full Text Index

sparql
virtuoso

#1

What

The Virtuoso RDF Quad store supports optional Full Text indexing of RDF object values, providing optimal query 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 the bif:contains Full Text index function in SPARQL queries.

How

The Full Text index can be recreated as follows:

  1. Drop the table and its indexes:
   __atomic ( 1 ); 
   drop table DB.DBA.VTLOG_DB_DBA_RDF_OBJ; 
   drop table DB.DBA.RDF_OBJ_RO_FLAGS_WORDS; 
   __atomic ( 0 );
  1. Create the index again 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); 
  1. Then the index can be filled again with command:
  DB.DBA.RDF_OBJ_FT_RECOVER(); 

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