I have a product table that contains thousands of products. Some products are available in different colors. But when somebody searches for example 'mp3 player' i dont want to show him every color, instead just the player with the best selling color.
Her is the table layout (simplified):
ID | PRODUCT_NAME | COLOR | SALE_COUNT
===========================================
1 | Mp3 player red | red | 2
2 | Mp3 player gold | gold | 1
3 | Mp3 player black | black | 100
But, when a user searches for 'Mp3 player red' i want to show him the red player, instead of the black one. The search is performed using the 'like' operator (yeah, i know lucene, anyway i need to solve this).
Any suggestions how to solve this issue? i have a few ideas but none of them seems to be a good solution. thanks,
postgreSQL db and jave is used to create the result.