Link to home
Start Free TrialLog in
Avatar of RTKHOT
RTKHOTFlag for India

asked on

Better search feature

I have a search tool in my website that returns all items (database = sql server) that contain the search string.

Presently, if I type 'red shirts' into search, it returns all records that contain this string in the description field of the items

Now, i need to modify it.

If an item description contains "shirt - red", then also the above search string (red shirts) should return such items. In other words, my search result should return all items that contain one or more words that were entered in the search irrespective of their sequence (red shirt or shirt - red)

How should I modify my database query?
Avatar of Habib Pourfard
Habib Pourfard
Flag of New Zealand image

You can use full text search, Full-text search is an optional component of the SQL Server Database Engine.

USE AdventureWorks2008R2;
FROM Production.Product
WHERE CONTAINS(Name, ' "Mountain" OR "Road" ')

Open in new window

Querying SQL Server Using Full-Text Search
Avatar of RTKHOT


So do i have to first split all the words in the search text box and use as above with the OR seperator?
Avatar of Habib Pourfard
Habib Pourfard
Flag of New Zealand image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial