views:

51

answers:

2

I have 2 seperate systems - a document management system and a sharepoint search server.

Both systems have an api that I can use to search the data within them. Tthe same data may exist in both systems, so we much search both.

What is the most efficient way (speed is very important) to search both api's at the same time and merge the results together.

Is the following idea bad/good/slow/fast:

  1. user enters search terms
  2. the api for each system is called on it's own thread
  3. the results from each api is placed in a common IEnumerable class of same type
  4. when both threads have executed linq is used to join the 2 IEnumerable result objects together
  5. results are passed to view

The application is ASP.NET MVC C#.

+1  A: 

Your solution looks alright - you're using the adapter pattern to convert the two different result feeds into your required format, and the overall design is a facade pattern. From a design point of view, your solution is valid.

If you wanted to make things even better, you could display the results as soon as they arrive and display a notification that results are still loading until all APIs have returned a value. If your document management system was significantly faster or slower than sharepoint, it would give the user information faster that way.

Sohnee
+1 for the Adapter
Chris Missal
A: 

I don't see anything wrong in the way you are doing it. Your algorithm could take forever to produce the perfect results, but you need to strike a balance. Any optimisation would have to be done in the search algorithm (or rather document indexing). You would still have to compromise on how many hits are good enough to the user by limiting the duration of your thread execution.

jeyoung