Solved

SQL Full Text search containg hyphen "-"

Posted on 2004-08-28
10
1,471 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
ID: 11926249
Try it this way:

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

Author Comment

by:stratton65
ID: 11927650
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
ID: 11928037
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
ID: 11928045
Also, please indicate the language you are using.  In other words, I am interested to find out the noise.* file used.
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:stratton65
ID: 11931231
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
ID: 11931534
>>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
ID: 11931659
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
ID: 11931985
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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

863 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

21 Experts available now in Live!

Get 1:1 Help Now