I’m using Microsoft SQL Server 2008. I’m not an expert with it but I created a full-text index and have been writing some queries.
It’s working without errors and is returning some results, but rows I know should match are not always included.
Is there anyway to verify or inspect the index? I went in several times and “repopulated the index” so I’m pretty sure it’s right. But what do you do when you don’t seem to get the right results.
My query is fairly complex but here it is if anyone is thinking that’s the problem:
DECLARE @StartRow int;
DECLARE @MaxRows int;
SET @StartRow = 1;
SET @MaxRows = 10;
WITH ArtTemp AS
(SELECT TOP (@StartRow + @MaxRows) ROW_NUMBER() OVER (ORDER BY ArtViews DESC) AS RowID,
Article.ArtID,Article.ArtTitle,Article.ArtSlug,Category.CatID,Category.CatTitle,
Article.ArtDescription,Article.ArtCreated,Article.ArtUpdated,Article.ArtUserID,
[User].UsrDisplayName AS UserName
FROM Article
INNER JOIN Subcategory ON Article.ArtSubcategoryID = Subcategory.SubID
INNER JOIN Category ON Subcategory.SubCatID = Category.CatID
INNER JOIN [User] ON Article.ArtUserID = [User].UsrID
WHERE CONTAINS(Article.*,'FORMSOF(INFLECTIONAL,"HTML")'))
SELECT ArtID,ArtTitle,ArtSlug,CatID,CatTitle,ArtDescription,ArtCreated,
ArtUpdated,ArtUserID,UserName
FROM ArtTemp
WHERE RowID BETWEEN @StartRow + 1 AND (@StartRow + @MaxRows)
ORDER BY RowID
In the query above, rows are returned. However, at least one row I know to contain the word “HTML” is not included.
Any troubleshooting tips?
I’m not a SQL expert, but ‘SELECT TOP (@StartRow + @MaxRows)’ to me translates as select the top 11 rows (start = 1 max = 10) that match the criteria, regardless of their RowID, not select from rows 1-10. Later you select your results ‘WHERE RowID BETWEEN @StartRow + 1 AND (@StartRow + @MaxRows)’, which means only show the rows with a RowID between 2-11. That may be why you aren’t receiving all of the results you are expecting. If that is not the case then I would make sure the rows you are expecting meet all of the join criteria.