A purchase signal records that a user bought an individual item associated with a search interaction. In e-commerce search, it indicates stronger product interest than a click or add-to-cart event and can improve ranking through a weighted signals boost. section 8.4 section 4.1.3
Represent each purchase using the generic signal fields:
- query_id links the purchase to the originating search interaction. section 4.1.3
- user identifies the shopper, type is purchase, target identifies the purchased document or item, and signal_time records when it occurred. section 4.1.3
- Aggregate purchases with other signals instead of treating them as isolated events; one purchase can receive a weight of 25 versus 1 for a click and 10 for an add-to-cart. section 8.4
From search to purchase
A user searches for “ipad,” clicks doc1 and doc3, adds doc3 to the cart, then searches for “ipad cover,” clicks and adds doc4, and purchases doc3 and doc4. The purchase events retain their respective query IDs, item targets, user, and timestamp, allowing each purchase to contribute to query-document relevance. section 4.1.3
Listing 8.6 Combining multiple signal types with different weights
mixed_signal_types_aggregation_query = """
SELECT query, doc, ((1 * click_boost) #1
+ (10 * add_to_cart_boost) + #1
(25 * purchase_boost)) AS boost FROM ( #1
SELECT query, doc,
SUM(click) AS click_boost, #2
SUM(add_to_cart) AS add_to_cart_boost, #2
SUM(purchase) AS purchase_boost FROM ( #2
SELECT lower(q.target) AS query, cap.target AS doc,
IF(cap.type = 'click', 1, 0) AS click,
IF(cap.type = 'add-to-cart', 1, 0) AS add_to_cart,
IF(cap.type = 'purchase', 1, 0) AS purchase
FROM signals cap LEFT JOIN signals q on cap.query_id = q.query_id
WHERE (cap.type != 'query' AND q.type = 'query')
) raw_signals
GROUP BY query, doc) AS per_type_boosts"""
type_weighted_collection = \
aggregate_signals(signals_collection, "signals_boosts_weighted_types",
mixed_signal_types_aggregation_query)
This SQL aggregation separates signal types, counts purchases per query-document pair, and combines them with configurable click and add-to-cart weights. section 8.4
