While you have a website selling product, data structures as follows:
Web-styled application usually have two entrance: Search and Browse.
When you input term and search, the result order will be descent by matched "score", normally it is fine.
But how about products have the same score? Lucene and a lot of search libraries sort them by index order.
That will be a problem, especially in Browse mode.
Base on the data from above picture, if I query skus for catalog under "Laptop Accessories", results will be:
No. | Name |
---|---|
1 | Brand-1 Laptop Chill Mat |
2 | Brand-1 Metro Roller Notebook Bag |
3 | Brand-1 Laptop/LCD Privacy Filter |
... | ... |
7 | Brand-2 Laptop Chill Mat |
8 | Brand-2 Metro Roller Notebook Bag |
9 | Brand-2 Laptop/LCD Privacy Filter |
See? Brand-1's product might be above all other brands, it is unfair to Brand-2.
To solve the issue, we need to set a secondary sort field/column after score (let's say "rank"), to handle the cases when score is same.
Firstly have an order with catalog:
In this case lower level dimensions will have higher rank. You can write your own business order, set whatever catalog higher you want in the same nav level.
Next design an encoding method for field rank value.
For example, put the catalog rank# in the first of rank, with given a sequence# follows for each brand:
After all, query with rank desc, you'll see products is show with brand mixed.
No. | Name | Rank |
---|---|---|
1 | Brand-2 Laptop/LCD Privacy Filter | 83 |
2 | Brand-1 Laptop/LCD Privacy Filter | 83 |
3 | Brand-2 Metro Roller Notebook Bag | 82 |
4 | Brand-1 Metro Roller Notebook Bag | 82 |
5 | Brand-2 Laptop Chill Mat | 81 |
6 | Brand-1 Laptop Chill Mat | 81 |
... | ... | ... |
Field rank encoding is not simple, it is hard. Above example may not have good experience while Brand-1's product is more than Brand-2's (vice versa), and don't have product factor (promo, seller, stock etc.) support. But it is the basic way to solve the issue.
About factor of rank algorithm will be in another topic.
28 Feb 2015