I am throwing this question out to the 'greater creativity' for some suggestions on search methodology that might solve this problem. I have come up with a somewhat contrived example to attempt to explain the problem well enough that some solution(s) might be recommended.

The problem: We are using a relational DB (MSSQL) and need to search across products with the following constraints:

  • Availability
  • Market
  • Price

We also need to group and sort on - price - market - larger entity roll-up

Let me see if I can explain using semi-real world entities:

Think of an application that allows users to search for hotel rooms that they can book. The following criteria might be available for the search: - Days that the rooms would be booked for - The market in which they want a hotel room (NYC, Boston, etc.) - Amenities that the hotel room(s) might have (hot tub, fireplace - Number of beds - Suite or not

In all cases, the search criteria above may or may not be selected. So, a very broad search is possible (on these dates, don't care which market) or varying levels of specificity (in NYC, 2 beds, with fireplace).

To add complexity, we also need to return the prices of the hotel rooms for the selected criteria. Obviously, special pricing, different prices for the different days of the stay (one price on Thursday night and a different price on Friday and Saturday nights for a weekend stay).

Some of the things we've played around with are: - Solr - Endeca - SQL querying - Implementing in C# code and optimizing when/where necessary (think Decorator Pattern)

What I'm looking for here is some suggestions from the community on - Which of the above is NOT suited for this problem - Which might be well suited for this problem - Which other technology might work better that we haven't thought about - Techniques that others have used on similar problems that worked well (non-technology specific)

Thank you in advance for any idea or suggestions you may have. I am going to attempt to apply appropriate tags to this question, but am open and can add/remove to help get the right brains on it.

有帮助吗?

解决方案

What you are describing boils down to entities that have attributes. I have spend a lot of time on a similar problem where the entities in my case where products and the attributes could be anything (e.g. category, condition, price, color etc.). Products did not have to share attributes, althought there was a common set.

The solution I eventually arrived at was to use lucene (.net in my case). However I would recommend you use Solr as it is easier to use its filtering capabilites (there was a specific reason I couldn't use it, but it is probably the easier solution...although it was very easy to get up and running on Lucene.net). The basic idea is that you create documents with your attributes as properties. Then design some object that you can pass to your search code that lists the attributes the people are searching on the the values they want to filter on. After that it is quite easy to use that object to build up a query in Lucene that retrieves the documents you want.

It is relatively trivial to implement paging if that is required. One advantage I found with Solr was that it could easily count groups of attributes (e.g. I could search for "Nikon" and as well as returning all the documents with "Nikon" in them it could group the attributes, such as the different categories or different colors....you can do this with Lucene but its more work).

I settled on Lucene after looking at various search options, having spend a fair bit of time implmenting the functionality using SQL Server's search capabilities, but I found Lucene to be faster and it look the load off my DB server (and I gather Stack OverFlow itself moved from using SQL Server's search to Lucene) Stack Overflow Search

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top