File tree Expand file tree Collapse file tree 4 files changed +33
-22
lines changed
app/services/discovery_engine Expand file tree Collapse file tree 4 files changed +33
-22
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
1
+ module DiscoveryEngine ::Boosts
2
+ class BestBets
3
+ def initialize ( query_string )
4
+ @query_string = query_string
5
+ end
6
+
7
+ def boost_specs
8
+ return unless best_bets_for_query . any?
9
+
10
+ [ {
11
+ boost : 1 ,
12
+ condition : "link: ANY(#{ condition_links } )" ,
13
+ } ]
14
+ end
15
+
16
+ private
17
+
18
+ attr_reader :query_string
19
+
20
+ def best_bets_for_query
21
+ Array ( Rails . configuration . best_bets [ query_string ] )
22
+ end
23
+
24
+ def condition_links
25
+ best_bets_for_query . map { "\" #{ _1 } \" " } . join ( "," )
26
+ end
27
+ end
28
+ end
Original file line number Diff line number Diff line change 1
- module DiscoveryEngine
2
- module NewsRecencyBoost
1
+ module DiscoveryEngine :: Boosts
2
+ class NewsRecency
3
3
FRESH_AGE = 1 . week
4
4
RECENT_AGE = 3 . months
5
5
OLD_AGE = 1 . year
6
6
ANCIENT_AGE = 4 . years
7
7
8
- def news_recency_boost_specs
8
+ def boost_specs
9
9
[
10
10
{
11
11
boost : 0.2 ,
Original file line number Diff line number Diff line change @@ -3,9 +3,6 @@ class Search
3
3
DEFAULT_PAGE_SIZE = 10
4
4
DEFAULT_OFFSET = 0
5
5
6
- include BestBetsBoost
7
- include NewsRecencyBoost
8
-
9
6
def initialize (
10
7
query_params ,
11
8
client : ::Google ::Cloud ::DiscoveryEngine . search_service ( version : :v1 )
@@ -53,8 +50,8 @@ def serving_config
53
50
def boost_spec
54
51
{
55
52
condition_boost_specs : [
56
- *news_recency_boost_specs ,
57
- *best_bets_boost_specs ( query ) ,
53
+ *Boosts :: NewsRecency . new . boost_specs ,
54
+ *Boosts :: BestBets . new ( query ) . boost_specs ,
58
55
] ,
59
56
}
60
57
end
You can’t perform that action at this time.
0 commit comments