Commit 1dead2d120d270ade9c92e0b6c1ed662442fcb50
1 parent
2bbd3885
Exists in
master
and in
21 other branches
Added boost
Showing
1 changed file
with
10 additions
and
5 deletions
Show diff stats
README.md
... | ... | @@ -54,7 +54,7 @@ end |
54 | 54 | |
55 | 55 | ### Queries |
56 | 56 | |
57 | -Queries are just like SQL. | |
57 | +Query like SQL | |
58 | 58 | |
59 | 59 | ```ruby |
60 | 60 | Product.search "2% Milk", where: {in_stock: true}, limit: 10, offset: 50 |
... | ... | @@ -93,6 +93,12 @@ Paginate |
93 | 93 | limit: 50, offset: 1000 |
94 | 94 | ``` |
95 | 95 | |
96 | +Boost by a field (give popular documents a little boost) | |
97 | + | |
98 | +```ruby | |
99 | +boost: "orders_count" | |
100 | +``` | |
101 | + | |
96 | 102 | ### Facets |
97 | 103 | |
98 | 104 | ```ruby |
... | ... | @@ -138,9 +144,9 @@ class Product < ActiveRecord::Base |
138 | 144 | end |
139 | 145 | ``` |
140 | 146 | |
141 | -### Get Better Over Time | |
147 | +### Get Better With Time | |
142 | 148 | |
143 | -Improve results with analytics on conversions and give popular documents a little boost. | |
149 | +Improve results with analytics on conversions. | |
144 | 150 | |
145 | 151 | First, you must keep track of search conversions. The database works well for low volume, but feel free to use redis or another datastore. |
146 | 152 | |
... | ... | @@ -162,8 +168,7 @@ class Product < ActiveRecord::Base |
162 | 168 | def _source |
163 | 169 | { |
164 | 170 | name: name, |
165 | - conversions: searches.group("query").count.map{|query, count| {query: query, count: count} }, # TODO fix | |
166 | - _boost: Math.log(orders_count) # boost more popular products a bit | |
171 | + conversions: searches.group("query").count.map{|query, count| {query: query, count: count} } | |
167 | 172 | } |
168 | 173 | end |
169 | 174 | end | ... | ... |