|
|
Question : Better Search - Full-Text Indexing?
|
|
|
|
I need to create a search for my ASP.NET/C# site. We're using SQL Server 2000.
This is what I'm doing temporarily (which is obviously not a great way to do it)--
I have a view created with the following: SELECT p.Id , c.CategoryName , m.name AS ManufactureName , p.ProductName , p.ProductDesc AS ProductDescription , p.ProductDesc1 AS ProductDetail , p.ImageName
, (c.CategoryName + ' ' + p.productname + ' ' + m.name + ' ' + p.ProductName + ' ' + Convert(nvarchar(max), p.ProductDesc) + ' ' + Convert(nvarchar(max), p.ProductDesc1)) As 'KitchenSink' FROM dbo.Products AS p INNER JOIN dbo.Manufacturer AS m ON p.ManufacturerId = m.Id INNER JOIN dbo.Category AS c ON p.CategoryId = c.id WHERE (p.IsActive = 1) AND (c.IsActive = 1) AND (m.IsActive = 1) AND (p.isCatalog = '0')
Then from my webpage, I'm calling a stored proc that basically selects everything from that view where "KitchenSink Like '%whatever%search%string%'.
How can I do a better search?
I was looking in to Full-Text Indexing but didn't know if I'd need to index the view (which I'm running into snags on because the ProductDesc and ProductDesc1 fields are text fields and I can't create an index on the view because of that, the error says).
Can I index the multiple tables somehow and search? I'm a complete newbie to Full-Text Indexing so any help would be SO appreciated.
|
|
|
|
Answer : Better Search - Full-Text Indexing?
|
|
Full text indexing is one way to go. Another way would be to create a keywords table and have a productskeyword join table. You could have a trigger on insert/update to add to the 2 tables.
For example Products ItemID ItemDescription 1, 100% cotton short sleeve t-shirt 2, 50/50 cotton poly blend
Keywords KeywordID, Keyword 1, Cotton 2, short 3, sleeve 4, t-shirt 5, shirt -- if you decide to do words with/without prefix/suffix/stems/plurals, etc 6, long 7, long sleeve -- if you allow phrases 8, blend
ItemKeywords ItemID, KeywordID 1,1 1,2 1,3 1,4 1,5 2,1 2,8
Now, you can simply do your select with JOIN ItemKeywords ik ON ik.ItemID = products.ItemID JOIN Keywords k ON k.KeywordID = ik.KeywordID
|
|
|
|