Robert W.B. Linn´s Software, Beispielprojekte und Tipps zu TurboDB, TurboDB VCP, TurboDB Studio, Visual Data Publisher
   
Howto ... Create a Full Text index at runtime, using CreateTable()?
TurboDB VCL Übersicht  Alle Topics 
Komponenten TurboDB und TMS Component Pack  »  TurboDB - HowTo  »  Howto ... Create a Full Text index at runtime, using CreateTable()?  | 

The fulltext indexing is not supported for Unicode fields for TurboDB version 4.19 (and lower) and following
workaround is needed. To create a fulltext index at runtime you have to perform the following steps:

1. Create the keyword table

  The structure has to be: string, smallint, autoinc:
  FIndexTable := TTdbTable.Create(nil);
  FIndexTable.DatabaseName := 'DB1';
  FIndexTable.TableName := 'FTIndex';
  FIndexTable.FieldDefsTdb.Add('Keyword', dtString, 30);
  FIndexTable.FieldDefsTdb.Add('Frequency', dtSmallInt);
  FieldDef := FIndexTable.FieldDefsTdb.Add('RecordId', dtAutoInc);
  FieldDef.Specification := 'Keyword';
  FIndexTable.CreateTable;

2. Create the main table containing a relation field, the linked table is the keyword table:

  FMainTable := TTdbTable.Create(nil);
  FMainTable.DatabaseName := 'DB1';
  FMainTable.TableName := 'FTMaster';
  FieldDef := FMainTable.FieldDefsTdb.Add('RecordId', dtAutoInc);
  FieldDef.Specification := 'RecordId';
  FMainTable.FieldDefsTdb.Add('Alpha1', dtString, 30);
  FMainTable.FieldDefsTdb.Add('Alpha2', dtString, 255);
  FMainTable.FieldDefsTdb.Add('Memo1', dtMemo);
  FMainTable.FieldDefsTdb.Add('Memo2', dtMemo);
  FieldDef := FMainTable.FieldDefsTdb.Add('Keywords', dtRelation);
  FieldDef.Specification := 'FTIndex.dat';
  FMainTable.CreateTable;
  // tell the main table that there is a fulltext table
  FMainTable.FullTextTable := FIndexTable;

3. Call UpdateFulltextIndex method:

  FMainTable.UpdateFulltextIndex('Alpha1,Alpha2,Memo1,Memo2', 'Keywords', '', 1000);
Tested with TurboDB 4 für VCL.


Letzte Änderung 02.01.2012 18:54 Erstellt mittels KALHelp Version 6.8 (02-01-2012) (alle Rechte vorbehalten) (c) Robert W.B. Linn @53° 38' 60''N 9° 48' 0''E