Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Keyword search with SQL Server

I have a scenario where I need to search for cars by keywords using a single search field. The keywords can relate to any of the car's attributes for e.g. the make or the model or the body style. In the database there is a table named 'Car' with foreign keys referencing tables that represent models or makes or body style.

What would be the best way of doing this? Specifically, How should I take the query from user(must support exact phrase search, or, and) and how do I actually do the search.

I am using SQL Server and ASP.NET 3.5 (Data access using LINQ)

like image 826
Ali Kazmi Avatar asked Feb 12 '26 18:02

Ali Kazmi


2 Answers

Easily the best and most comprehensive article on the subject : http://www.sommarskog.se/dyn-search-2005.html

like image 90
Aaron Bertrand Avatar answered Feb 14 '26 08:02

Aaron Bertrand


Regardless of which implementation you pick from Aaron's article, I always log the search criteria and execution time in this situation. Just because you provide search flexibility, it doesn't mean most users will make use of it. You usally find most searches occur on a limited number of fields and logging the search criteria will allow you to create targetted indexes.

like image 32
Dave Barker Avatar answered Feb 14 '26 08:02

Dave Barker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!