views:

175

answers:

3
+1  Q: 

Best way to Search

I am building a real estate website. I have a table for properties (i.e. "houses"), a table for pictures, a table for features, etc. So each property's data comes from three, not only one table.

I need to provide a function that retrieves requested property data depending on a search criteria, for example:

  1. property of the week
  2. featured properties
  3. properties on offer
  4. the simple search

I have multiple drop-down lists for selecting country, region, area, bedrooms, price range, type, etc.

I already built many functions each dealing with one of the above cases, but I was wondering, if there was any other way of building one flexible mechanism that will retrieves whatever you want in a smart way, I mean one function that works for all cases?

I know my question is kind of vague and too broad, but bear with me please.

Thanks in advance.

PS: I am using ASP.NET 3.5, VB.NET, Visual Web Developer 2008 Express, SQL Server 2005 Express

+1  A: 

I think you're looking to build an Advanced Search functionality that integrates with the default/simple search provided.

Why not build a single stored procedure to encapsulate all possible types of searches by specifying default values of parameters that are not passed.

In this manner, the simple search would be using all parameter defaults. Whenever any criteria is provided to narrow the search, the passed parameter value will be used by the Stored Procedure.

Cerebrus
A: 

Is Lucene an option? Lucene.net is a great way to provide a quick and flexible search engine to your site. When you use Lucene you also many other advantages, like fuzzy search etc...

http://www.codeproject.com/KB/library/IntroducingLucene.aspx

bob
A: 

The question is twofold:

  1. Can you logically unite the search for "properties of the week" and the search for "properties in this specific region, costing 100,000 or less" into a single database search?
  2. Does it buy you anything to think of/create something that does 1.)? (Especially when you already have something that works.)

If you would answer both questions with "Yes", then I'd say you must extend the simple search. I suppose you already have a flag for each of your special cases ("property of the week", "property on offer", etc). Just add support for these flags to your simple search function.

Provide reasonable defaults for the search criteria and you can use simple search for all the cases you described.

Tomalak