Subject | Re: [IBO] example of using TIB_FTS_Search, I simply can not get this to work |
---|---|
Author | robert.gilland |
Post date | 2009-05-18T07:09:08Z |
> Have you looked at the separate IB_FTS.hlp file?I could not find this.
>
> It has screen shots and instructions.
>I have been able to implement a simple interface to IBO FTS.
> I also encourage you to get the IBO 4.9 Beta because there are some
> improvements and bug fixes for the Full Text Searching functionality. Both
> in the components and in the application IB_FTS.dpr.
I will add the procedures below. I think if you could have an example like the Below in the Help file it would have saved me a weeks work.
What I want to do is to limit a join query not just one table.
Will IBO4.9 allow us to do it. Moving version of IBO is a major drame for us.As we have to release new packages to all our customers.
I want to limit as below:
SELECT T1.KEY, T1.DESC
FROM TABLE1 T1
JOIN TABLE2 T2
ON( T1.KEY = T2.KEY )
Could I do this?
Below is a simple implemetation of FTS:
I hope it helps those who want
procedure TdatFTS.EnsureSearchIndexesAvailable;
var
fts : TftsI;
piName : String;
begin
if not ConnectDB then
exit;
if( not ftsMeta.BaseLoaded )then
begin
ftsMeta.LoadBase;
Connected := FALSE;
Connected := TRUE;
end;
cdsFTS.Open;
for fts := Low( TftsI ) to High( TftsI ) do
begin
if( cdsFTS.FindKey([ftsIndexNames[fts]]))then
continue;
piName :=
MetaDataObj.GetPrimaryIndexName(ftsTableNames[fts]);
cdsFTS.Insert;
cdsFTS.FieldByName('FTS$IND_NME').AsString :=
ftsIndexNames[fts];
cdsFTS.FieldByName('FTS$TBL_NME').AsString :=
ftsTableNames[fts];
cdsFTS.FieldByName('FTS$KEY_COL').AsString :=
ftsKeyColumns[fts];
cdsFTS.FieldByName('FTS$AUX_COL').AsString :=
ftsKeyColumns[fts];
cdsFTS.FieldByName('FTS$SCH_COL').AsString :=
ftsSrchColumns[fts];
cdsFTS.FieldByName('FTS$SCH_LEN').AsInteger :=
ftsSearchLen[fts];
cdsFTS.FieldByName('FTS$WRD_LEN').AsInteger := 30;
cdsFTS.FieldByName('FTS$MIN_LEN').AsInteger := 2;
cdsFTS.FieldByName('FTS$USR_LEN').AsInteger := 32;
cdsFTS.FieldByName('FTS$KEY_TYP').AsString := ftsKeyTypes[fts];
cdsFTS.FieldByName('FTS$KEY_DM').AsString := ftsKeyTypes[fts];
cdsFTS.FieldByName('FTS$WDS_TYP').AsString :=
'VARCHAR(' + IntToStr(ftsSearchLen[fts]) + ')';
cdsFTS.FieldByName('FTS$KEY_IND').AsString := piName;
cdsFTS.FieldByName('FTS$STATUS').AsString := 'I';
cdsFTS.FieldByName('FTS$LOG').AsString := 'T';
cdsFTS.Post;
end;
SaveBeforeClose(cdsFTS);
cdsFTS.Close;
for fts := Low( TftsI ) to High( TftsI ) do
begin
ftsMeta.SearchIndexName := ftsIndexNames[fts];
ftsMeta.ResetVariables;
if( not ftsMeta.IsMetaLoaded )then
begin
ftsMeta.LoadIndexMeta;
RefreshConnections;
end;
ftsMeta.ResetVariables;
if( not ftsMeta.IsPopulated )then
begin
ftsMeta.PopulateIndex;
RefreshConnections;
end;
ftsMeta.ResetVariables;
if( not ftsMeta.IsActivated )then
begin
ftsMeta.ActivateIndex;
RefreshConnections;
end;
end;
DisConnectDB;
end;
procedure TdatFTS.FastSearch(ftsI: TftsI;
var SearchFor: String;
ds : TDatasetObject);
var
i,j : Integer;
ro : TRecordObject;
begin
if not ConnectDB then
exit;
ftsSearch.SearchIndexName := ftsIndexNames[ftsI];
ftsSearch.ResetVariables;
ftsSearch.SetSearchWordsString(SearchFor,tstWordPartial);
qrySearch.KeyRelation := ftsTableNames[ftsI];
qrySearch.KeyLinks.Text := ftsKeyColumns[ftsI];
with qrySearch.SQL do
begin
clear;
add('SELECT ' + ftsKeyColumns[ftsI]);
add(',' + ftsSrchColumns[ftsI]);
add('FROM ' + ftsTableNames[ftsI] );
end;
qrySearch.Open;
qrySearch.First;
ds.Clear;
j := 0;
while( not qrySearch.Eof )do
begin
ro := TRecordObject.Create;
for i := 0 to qrySearch.Fields.ColumnCount-1 do
begin
ro.AddUpdateFieldValue(
qrySearch.Fields.Columns[i].FieldName,
qrySearch.Fields.Columns[i].Value );
end;
inc(j);
ds.AddObject(IntToStr(j),ro);
qrySearch.Next;
end;
qrySearch.Close;
DisConnectDB;
end;
procedure TdatFTS.qrySearchPrepareSQL(Sender: TIB_Statement);
begin
ftsSearch.PrepareSQL(qrySearch);
end;
procedure TdatFTS.qrySearchBeforeExecute(Sender: TIB_Statement);
begin
ftsSearch.BeforeExecute(qrySearch);
end;
procedure TdatFTS.qrySearchAfterExecute(Sender: TIB_Statement);
begin
ftsSearch.AfterExecute(qrySearch);
end;
procedure TdatFTS.RefreshConnections;
begin
DisconnectDB;
ConnectDB;
end;