Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 RLIKE or REGEXP ???

Author  Topic 

bumpy
Starting Member

6 Posts

Posted - 2004-09-08 : 16:42:22
Hello. I'm used to MySQL which has RLIKE and REGEXP. I'm trying to write a search engine with SQL Server, but I don't know how to specify "word boundaries". For example, when I write:

select * from products where long_desc like '%table%'

...I get back products with "adjustable" or "portable" in their descriptions. I also need to consider descriptions that begin with the word "table", for example.

How can this be done with SQL Server?

Thanks!!!

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-09-08 : 19:50:49
Have a look into Full Text Indexing. It's in Books Online.


Damian
Go to Top of Page

bumpy
Starting Member

6 Posts

Posted - 2004-09-08 : 19:55:12
I guess I should mention that I'm using SQL Server 7, and I do not have access to Enterprise Manager or any stored procedure type of stuff. I'm using only PHP to communicate with this DB.

What is Books Online? When I search for Full Text Indexing on MSDN, it shows me Exchange Server docs.

Thanks,
Matt
Go to Top of Page

Merkin
Funky Drop Bear Fearing SQL Dude!

4970 Posts

Posted - 2004-09-08 : 20:53:30
Books Online is the product documentation for SQL Server. If you install the developer or trial edition you will get it.

Full Text works with 7, but you need proper access to get it set up. Can you talk to the administrator of the server ?


Damian
Go to Top of Page

bumpy
Starting Member

6 Posts

Posted - 2004-09-10 : 12:43:32
Okay, the admin has turned on Full Text Indexing. I can now use the CONTAINS predicate. However, it returns no results. I read the MSDN page on using CONTAINS, and I know I'm doing it correctly.

Is there more to setting up Full Text Indexing than merely selecting which columns and on which table?

Thank you so much!
Matt
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2004-09-10 : 12:54:01
quote:
Originally posted by bumpy

However, it returns no results....and I know I'm doing it correctly.



I always love this....

And HOW do you know you're doing it correctly?

Post the code so we can see...



Brett

8-)
Go to Top of Page

bumpy
Starting Member

6 Posts

Posted - 2004-09-10 : 13:27:46
I read the syntax for the CONTAINS predicate. I tried the following queries:

select * from products where contains(long_desc, 'table')
select * from products where contains(long_desc, '*table*')
select * from products where contains(long_desc, ' "table" ')
select * from products where contains(long_desc, '"*table*"')

And I get 0 rows back every single time.

If I try:

select * from products where long_desc like '%table%'

Then I get back 91 rows. What's up?


Thanks,
Matt
Go to Top of Page

DustinMichaels
Constraint Violating Yak Guru

464 Posts

Posted - 2004-09-10 : 13:30:18
Is the full text index populated? I'm no expert on the subject but I think you have to run a command to populate the index before you use full text queries.
Go to Top of Page

bumpy
Starting Member

6 Posts

Posted - 2004-09-10 : 19:46:44
My admin said he did populate it. He now thinks the problem has to do with permissions. Does that sound remotely plausible?

Thanks,
Matt
Go to Top of Page

bumpy
Starting Member

6 Posts

Posted - 2004-09-13 : 14:14:15
Ahh! It works now. The sysadmin said that there was an issue with users. (He's not really a DB admin.)

My problem now is that the searches don't handle verb conjugations and plurals the way I heard Full Text Indexing can do. Is this functionality only provided with SQL Server 2000 and not version 7?

Thanks,
Matt
Go to Top of Page
   

- Advertisement -