Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Set Full Text Search to treat Numbers at Text Sql Server 2008 R2

Posted on 2014-09-02
5
Medium Priority
?
1,335 Views
Last Modified: 2014-09-07
Hello

I am testing setting up a Full Text Search and I am having issues when trying to search for a Numbers.

If I search for contains(ColumnA,'"5"')
It will only return rows that have "5"
It won't return rows that contain "5mm" or "5Ltr"

Can I make it treat all Numbers as Text?


Also if I search for contains(ColumnA,'"2.5m"')
It will return results that contain "2.5m" AND results that contain "25m" (It searches for the decimal point then drops it and joins the "2" and the "5m" together)

Thanks
0
Comment
Question by:p-plater
[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
  • 3
  • 2
5 Comments
 
LVL 25

Expert Comment

by:chaau
ID: 40300235
To make the CONTAINS to search from the beginning of the string you need to use *, like this:
 contains(ColumnA,'"5*"')

Open in new window

Please note that punctuation is ignored in full text search (when you search for 2.5m the decimal point is a full stop punctuation as far as SQL Server is concerned ). here is the quote from MSDN:
Punctuation is ignored. Therefore, CONTAINS(testing, "computer failure") matches a row with the value, "Where is my computer? Failure to find it would be expensive." For more information on word-breaker behavior, see Configure and Manage Word Breakers and Stemmers for Search.
.
If you wish to do the exact search use LIKE:
ColumnA LIKE '%2.5m%'

Open in new window

0
 

Author Comment

by:p-plater
ID: 40300355
Hello Chaau

I Have been using '"5*'" and '"2.5m*"' - Just missed out putting it on the ticket!! Sorry.

I'm trying to use Full text Search as it is about 4 Times faster than Like on this project

There must be some way to make it search the "."
0
 
LVL 25

Expert Comment

by:chaau
ID: 40300723
All numbers are in the stop list. You can remove the numbers from there. However, it is very difficult to get full text to search "like Google". The punctuation is the trickiest part. I guess you need to either use LIKE or store the key words in an index table
0
 

Author Comment

by:p-plater
ID: 40302288
I have removed the Stop Words list from the Index.

My other Option is to Replace all full stops with something else Like |,^,~,<,>,{,},[,]

Do you know if any of these characters get dropped like the full stop?
0
 
LVL 25

Accepted Solution

by:
chaau earned 2000 total points
ID: 40302394
Fulltext indexes words. The "word" in its view is a continuous string of characters without spaces or punctuation. The occurrence of a non-alphanumeric character breaks a word. Even if you specify SET STOPWORD=OFF during index creation the punctuation will break "words". You can try replace the full stops but you need to replace them to alpha sequence, i.e. "qwerty" Then your word will become:
2.5 => 2qwerty5
I think this is the only way
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

715 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