all groups > sql server full text search > january 2004 >
You're in the

sql server full text search

group:

Full Text Index Not Triggering on Row Insert.


Full Text Index Not Triggering on Row Insert. goosh NO[at]SPAM yahoo.com
1/29/2004 9:39:01 PM
sql server full text search:
Hi There.

I have a database table that I would like to integrate a full text
index on and have the table automatically rebuild the index on each
insert/update/delete. I think I have a good idea on the methodology
from reading through the posts, but I cannot get it to work on an
automatic basis, If I incrementally rebuild the index manually through
SQL enterprise then everything works great.

My table looks like this:

EntryID int,
EntryDescription char(30), /* This is the field that is full text
indexed */
TimeUpdated timestamp

At this point, I should point out that I'm dealing with a database
built awhile back that has many applications tied into it. Therefore,
I was able to add the timestamp field without any affect to existing
applications but I am unable to change the Description field to
another data type without adverse effects. I only point this out as I
am not sure if the fact that it's not a text field has anything to do
with my problem.

So, then under SQL Enterprise I have selected, under Full-Text Index:
* Change tracking
* Update Index in Background

My application then adds a new entry to this table using a standard
INSERT INTO stored procedure, and I can verify the entry was
successfully added by a simple SELECT query. However, any query that
looks for the new value using a text-indexed based query does not
return the new record until I manually rebuild the index.

As mentioned, I think I got all the steps and also realize that I
could use the method of scheduling an incremental build every X
minutes. However, I'd like to keep the application as "real time" as
possible so any help and/or thoughts is very much appreciated.

Thanks
Re: Full Text Index Not Triggering on Row Insert. John Kane
1/29/2004 11:36:20 PM
Jason,
Can I assume you're using SQL Server 2000? "Change tracking" and "Update
Index in Background" is what you're looking for and as I just recently
developed a test script for another thread, it worked as expected with SQL
FTS queries returning expected results after I did an INSERT. I can email
you the script for you to test if you want...

Could you post both the INSERT INTO stored proc and your "query that looks
for the new value using a text-indexed based query does not return the new
record"? This should of worked for you as well as it did for me, it's just
that we need to find why it failed to work successfully for you...

Regards,
John



[quoted text, click to view]

Re: Full Text Index Not Triggering on Row Insert. goosh NO[at]SPAM yahoo.com
1/30/2004 10:06:46 AM
Hi John,

I'm pretty sure it's 2000, how can I verify? I see XML support though
which I thought was new to 2000.

Anyways, the piece of the stored procedure that does the insert is:

"
If @Description <> ''

INSERT INTO LogDescriptions
(LogID, Description)
VALUES
(@ID, @Description)
"

Then, the search procedure is:

CREATE PROCEDURE dbo.LogsSearch

@TeamID int = 0,
@PlayerID int = 0 ,
@CategoryID int = 0,
@SubCategoryID int = 0,
@Keywords varchar(20) = '<blank>'
AS

If @Keywords = ''
SELECT @Keywords = '<blank>'

SELECT
M.MediaNum,
M.TimeIn,
M.Duration,
V.Abbreviation As Visitors,
H.Abbreviation as Home,
Q.Description As Quality,
D.Description
FROM LogMain M
JOIN Teams V ON M.VisitorsID = V.ID
JOIN Teams H ON M.HomeID = H.ID
JOIN zCategory C ON M.CategoryID = C.ID
JOIN zSubCategory SC ON M.SubCategoryID = SC.ID
JOIN zQuality Q ON M.QualityID = Q.ID
LEFT OUTER JOIN LogDescriptions D ON D.LogID = M.ID

/* Build Dynamic WHERE Clauses based upon input */
WHERE ((@Keywords <> '<blank>' AND CONTAINS (D.Description,
@KeyWords) ) OR @Keywords = '<blank>')


Thanks
Jason




[quoted text, click to view]
Re: Full Text Index Not Triggering on Row Insert. John Kane
1/30/2004 10:45:52 AM
Hi Jason,
You can use SELECT @@version -- to verify the exact SQL Server version,
including Service Pack (SP) level and OS Platform version as well. Both XML
and "Change Tracking" are new with SQL Server 2000...

The INSERT statement is stright forward, although, an Insert is only done if
the @Description value is not null, and I'm assuming that is true. While the
LogsSearch proc is a bit more complex. Could you retest using a simple
INSERT statement, and a simple CONTAINS statement, using a search word from
the INSERT statement, for example:

INSERT INTO FTSAccent values('Kahlúa HalfPipe jam', 'cafè', 'cafe', NULL)
....
select TextCol from FTSAccent where contains(TextCol,'"jam"')

Could you also confirm that "Change Tracking" and "Update Index in
Background" are turned on with your table LogDescriptions? Could you post
the results of the following SQL code?

use <your_database_name>
go
exec sp_help_fulltext_catalogs
select
objectproperty(object_id(N'LogDescriptions'),N'TableFulltextChangeTrackingOn
')
select
objectproperty(object_id(N'LogDescriptions'),N'TableFullTextBackgroundUpdate
IndexOn')
select
objectproperty(object_id(N'LogDescriptions'),N'TableFullTextPopulateStatus')
go

Thanks,
John


[quoted text, click to view]

Re: Full Text Index Not Triggering on Row Insert. goosh NO[at]SPAM yahoo.com
2/3/2004 4:07:29 PM
Hi John,

Well, I think I figured it out. I think it was working all along but
just taking a bit longer then expected (about 5 seconds). I expected
near real-time results so immediately upon my insert I would requery
and it would not show up... but after some more testing I'm finding it
does show up but not as quick as I would have anticipated.

Thanks for all your help though.

Jason


[quoted text, click to view]
Re: Full Text Index Not Triggering on Row Insert. John Kane
2/3/2004 4:35:24 PM
You're welcome, Jason,
There a built-in delay of approx. 1 second with "Change Tracking" and
"Update Index in Background" before the FT Catalog is updated, so depending
upon the number of inserts, you're most likely seeing this delay...

Regards,
John


[quoted text, click to view]
as
AddThis Social Bookmark Button