diff options
author | Lester Solbakken <lesters@yahoo-inc.com> | 2016-09-15 09:10:08 +0200 |
---|---|---|
committer | Lester Solbakken <lesters@yahoo-inc.com> | 2016-09-15 09:10:08 +0200 |
commit | 02c7750e9ff4db1796cf48a339f09335eb24b55f (patch) | |
tree | de09166cb02cc403023025566637597a39a309b8 /sample-apps/blog-recommendation | |
parent | 2d749a98fa0e459418f6da71f29e325ec2593d01 (diff) |
Only set ranking property if not already set
Diffstat (limited to 'sample-apps/blog-recommendation')
-rw-r--r-- | sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd | 2 | ||||
-rw-r--r-- | sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java | 7 |
2 files changed, 7 insertions, 2 deletions
diff --git a/sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd b/sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd index 5069b9302eb..4e424b59458 100644 --- a/sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd +++ b/sample-apps/blog-recommendation/src/main/application/searchdefinitions/blog_post.sd @@ -55,7 +55,7 @@ search blog_post { } - rank-profile default { + rank-profile tensor { first-phase { expression { sum(query(user_item_cf) * attribute(user_item_cf)) diff --git a/sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java b/sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java index c142c0e0986..d97d2898a41 100644 --- a/sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java +++ b/sample-apps/blog-recommendation/src/main/java/com/yahoo/example/BlogTensorSearcher.java @@ -35,7 +35,12 @@ public class BlogTensorSearcher extends Searcher { } QueryTreeUtil.andQueryItemWithRoot(query, notItem); - // Send the user profile to the ranking framework. + // Modify the ranking by using the 'tensor' rank-profile (as defined in blog_post.sd)... + // Send the user profile to the ranking framework. + if (query.properties().get("ranking") == null) { + query.properties().set(new CompoundName("ranking"), "tensor"); + } + + // ... and setting 'query(user_item_cf)' used in that rank-profile query.getRanking().getFeatures().put("query(user_item_cf)", toTensor(userItemCfProperty)); } |