Hi! On Thu, Aug 16, 2007 at 07:23:14PM +0200, Paul Lynch wrote: > Here's an example. Suppose you have a table "UsedCars" that looks like: > > Color Make Age > ------------------- > Green Saturn New > Green Saturn Old > Red Saturn New > Purple Toyota New > Purple Toyota Old > Blue Yugo Ancient > > The users searches on "Make", and the returned data to the user is a > combination of Color and Make. The user just wants to see the unique > values, i.e. > > Green Saturn > Red Saturn > Purple Toyota > Blue Yugo > > (or whichever of those match the query). I could get rid of the > duplicates (e.g. the two Green Saturns) after doing the query, but the > table is large, has a lot of duplicates, and I'm limiting size of the > return list, so if I get rid of duplicates then I may need to make a > second query to get more if it turns out that after getting rid of the > duplicates my list is too short. (Potentially, I could be left with > just one item to show.) > > In SQL, I could get the list like: > select distinct Color, Make from UsedCars limit 15 > > Is there a good way of doing that in ferret?
None that I know of - imho the best way to do this would be to use Ferret for just fetching the IDs of all matching records and then use these IDs with sql like above to let the database do it's job. > If not, would writing a filter be a good approach? I don't think a Filter would be a good way to solve this problem - Filter's don't have a clue about the query you're running, they just operate on bit vectors indicating which documents may appear in a query result, and which may not. Cheers, Jens -- Jens Krämer http://www.jkraemer.net/ - Blog http://www.omdb.org/ - The new free film database _______________________________________________ Ferret-talk mailing list [email protected] http://rubyforge.org/mailman/listinfo/ferret-talk

