Solved

SQL Full Text search containg hyphen "-"

Posted on 2004-08-28
10
1,449 Views
Last Modified: 2008-03-04
I am searching a database that contains descriptions of various millitary and commercial models.  I use full text indexing with the contains statement for almost all of these searches.  I need to be able to seach for planes like a B-17, F105, C-5, etc.  What I have learned is the FT search ignores the "-" hyphen.  It also then ignores the letter preceding the hyphen.  Which then leaves me searching for 17, 105, 5.  The first two return more results than I want, since lots of other items contain 17 or 105.  But the last is a problem since 5 by itself will also be ignored.  Is there a way to work around this?  Can I somehow force or trick the FT index into searching for the the full word including the hyphen?

0
Comment
Question by:stratton65
  • 5
  • 3
10 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
Try it this way:

SELECT *
FROM Table1
WHERE CONTAINS(*, '"B-17"')
0
 

Author Comment

by:stratton65
Comment Utility
Unless I'm doing something wrong, that yeilds the same result.  It only looks for the '17'

0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
I suspect there is a misuderstanding as to how Full-Text Search really works.  Post the row that contains "B-17" and I can give you more details.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
Also, please indicate the language you are using.  In other words, I am interested to find out the noise.* file used.
0
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

Author Comment

by:stratton65
Comment Utility
I'me working in English.  I have been able to work around it by using       FIELD LIKE "%B-17%"    instead of the CONTAINS statement.  The Full Text index will ignore the hyphen by design.

0
 
LVL 75

Expert Comment

by:Anthony Perkins
Comment Utility
>>FIELD LIKE "%B-17%" <<
If performance is not an issue, that that should be fine.  Just remember that using LIKE will probably force a sequential search.

>>The Full Text index will ignore the hyphen by design.<<
I am sorry that is not the way it works.  Do yourself a favor
1. Add a row with B-17 in it.  
2. Do a full-population and allow it to complete
3. When it has finished, do a search using: WHERE CONTAINS(*, 'B-17')

What is happening is that you have something like "AB-17" and expect Full-Text search to find that row with "B-17".  That is not going to happen.
0
 

Author Comment

by:stratton65
Comment Utility
This is the knowledge base article that deals with hyphens;

http://support.microsoft.com/default.aspx?scid=kb;en-us;200043

Unless I'm missing something, this is exactly how the hyphens behave in my environment.  

This is an example of the row;

B-17 G ‘Chow-hound’ -- This diecast Historically Accurate plane comes fully painted with pad-printing (no decals), and its own stand. Also included is Historical Information unique to this plane.

CONTAINS(*,'B-17')   will return this row as well as any row with a '17' in it.

DESCRIPTION LIKE '%B-17%'     returns only the rows I want.

There is a performance concern so I would really like to stick with Full Text if there is a way to make it work.
0
 
LVL 75

Accepted Solution

by:
Anthony Perkins earned 500 total points
Comment Utility
I see what you are getting at.  Unfortunately, I cannot duplicate the problem :)

Here is what I did.  
1. Created a table:
CREATE TABLE Table1 (
      ID int IDENTITY(1, 1) NOT NULL,
      Description text NULL)

2. Created a unique index on ID.

3. Added one row with the value:
B-17 G ‘Chow-hound’ -- This diecast Historically Accurate plane comes fully painted with pad-printing (no decals), and its own stand. Also included is Historical Information unique to this plane.

4. Added (Defined and did a Full Population) a full-text search on the Description column

5. Created a query with:
select * from table1 where CONTAINS(*, 'b-17')
And it returned that row.

Thinking there might be a problem with Prefix searches (as the article suggested) tried changing to CONTAINS(*, '"b-1*"'), the row was still returned.  I even tried: CONTAINS(*, '"pad-print*"').  Same result.

So, I would suggest you try the same.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
When you hear the word proxy, you may become apprehensive. This article will help you to understand Proxy and when it is useful. Let's talk Proxy for SQL Server. (Not in terms of Internet access.) Typically, you'll run into this type of problem w…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now