• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 221
  • Last Modified:

Full-Text Contains help needed

Hello, I need to find the best possible search method for a products table that has 4 columns indexed. This will be used on website where customers are searching for products.

When using

declare @SearchString varchar(1000) set @SearchString = '"word" and "of" and "promise"'
select productid, title
from productsearch
where CONTAINS((Contributor, PrimItemNumber, SecItemNumber, Title), @SearchString)

I get only these products:
173066      Every Promise Of Your Word : With Standing On The Promises
211181      Every Promise Of Your Word
211181      Every Promise Of Your Word
284043      Word of Promise Soundtrack    
293693      Word of Promise Next Generation New Testament (20 CDs)  
296904      Word of Promise Inspiration for Today (Vol. 1)

Not exactly a good pull.

I was expecting more along these lines:

Word of Promise - Complete Audio Bible (79 CDs)
Word of Promise - Complete Audio Bible (Download)
Word of Promise - Complete Audio Bible (MP3 Discs)
Word of Promise - New Testament Audio Bible (20 CDs)
Word of Promise Gift of Psalms
Word of Promise Inspiration for Today (Vol. 1)
Word of Promise Next Generation New Testament (MP3 Discs)
Word of Promise Next Generation New Testament (20 CDs)
Word of Promise Easter Story

Because of the "of" in the title I removed "of" from the stoplist. If not I get no results.

Why does the search perform so poorly? What is the best method to allow customers to search for products when they can type in either: author, isbn or title and half the time only know partial information of a title or authors name?

Any help is greatly appreciated!
1 Solution
Brian CroweDatabase AdministratorCommented:
Have you considered moving all of the searchable values into a separate table?  Something like:

CREATE TABLE ProductString
   ProductStringID INT IDENTITY(1,1),
   ProductID INT NOT NULL,
   StringTypeID INT NOT NULL,  --FK to type table containing Author, Title, ISBN, etc.
   String NVARCHAR(4000) NOT NULL

Obviously this could be fleshed out a little more but the general idea is to get all of the string in a single index.  I don't know that this would solve your search issues above but I would expect it to perform better and it would make localization easier down the road as you could just add a language field.

Just an idea
Anthony PerkinsCommented:
If you are searching for a phrase then the syntax is as follows:

DECLARE @SearchString varchar(1000) 

SET @SearchString = '"word of promise"'

SELECT  productid,
FROM    productsearch
WHERE   CONTAINS ((Contributor, PrimItemNumber, SecItemNumber, Title), @SearchString)

Open in new window

gogetsomeAuthor Commented:
Awe I see if I encapsulate with " " it works that way with contains as well.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now