?
Solved

SQL Full Text search containg hyphen "-"

Posted on 2004-08-28
10
Medium Priority
?
1,758 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 

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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
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…

719 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