views:

30

answers:

1

I have an Indexed View with two columns, a primary key char and a field for full-text indexing varchar(300). I need to search from a MS Great Plains database, so I created the view to populate a field with concatenated values from my primary table IV00101.

CREATE VIEW SearchablePartContent WITH SCHEMABINDING AS 
SELECT ITEMNMBR, rtrim(ITEMNMBR)+' '+rtrim(ITMSHNAM)+' '+rtrim(ITMGEDSC)
 as SearchableContent
FROM dbo.IV00101
GO
-- create the index on the view to be used as full text key index
CREATE UNIQUE CLUSTERED INDEX IDX_ITEMNMBR ON SearchablePartContent(ITEMNMBR)
CREATE FULLTEXT INDEX ON SearchablePartContent(SearchableContent) KEY INDEX IDX_ITEMNMBR ON Cat1_PartContent
WHILE fulltextcatalogproperty('Cat1_PartContent','populatestatus') <> 0
BEGIN
 WAITFOR DELAY '00:00:01'
END

The problem is that when I do a search with particular keyword(s) it will yield unexpected results. For instance a simple query such as:

SELECT * FROM SearchablePartContent WHERE CONTAINS(SearchableContent, 'rotor')

should yield 5 results, instead I get 1. There's about 72,000 records indexed. However, if I do a LIKE comparison, I will get the expected rows. My data is not complex, here are a couple results that should be returned from my query, but are not:

  1. MN-H151536 John Chopper, Rotor Assembly Monkey 8820,9600,8820FRT
  2. MN-H152756 John Rotor, Bearing 9650STS,9750STS1
  3. MN-H160613 John Rotor, Bearing 9650STS,9750STS2

Any help would be greatly appreciated. Thanks

A: 

Just a thought: Try enclosing your search term with double quotes to see if it makes a difference.

SELECT * FROM SearchablePartContent WHERE CONTAINS(SearchableContent, ' "rotor" ')
Joe Stefanelli
Thank you Joe, unfortunately that isn't the issue; I think the "" are meant for phrasing. As you can see the the three results I listed, there is nothing obscure about that data; those columns just aren't being indexed for some reason.
Alexander
I've heard of, but never personally experienced, cases where FTS acts case-sensitive despite what the database collation may be. Does searching 'Rotor' make a difference vs. 'rotor'?
Joe Stefanelli
Joe, not at all. Those 3 records I listed look pretty much the same as the results that do show up. Notice how #1 and #2 are fairly close. The other piece I forgot to mention is that when I narrow down my indexing to say.. 10,000 or 2,000 records, I can perform the same search and yield the correct results.
Alexander
For example, if you notice my query for creating my view. To narrow it I will tack on something like:FROM dbo.IV00101 WHERE ITEMNMBR LIKE 'MN-H15%' ...which will cut that 72,000 indexed view result set to maybe a thousand. Then I'll run my query and I will get the results I need.It's like FTS is nit-picking what it wants to index ...and I'm not sure on what.
Alexander
I'm running out of ideas, but it's really starting to sound like your fulltext index is not finished populating. I know PopulateStatus is deprecated for fulltextcatalogproperty. Try testing `OBJECTPROPERTYEX(OBJECT_ID(N'SearchablePartContent'), N'TableFulltextPopulateStatus') <> 0` instead and see if that makes any difference.
Joe Stefanelli
Nope, Nada.. same results. No errors in my logs either.
Alexander