Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changes view to impression #52

Merged
merged 4 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public class CoecClickModel extends ClickModel {

// UBI event names.
public static final String EVENT_CLICK = "click";
// TODO: Change "view" to "impression".
public static final String EVENT_VIEW = "view";
public static final String EVENT_IMPRESSION = "impression";

private final CoecClickModelParameters parameters;

Expand Down Expand Up @@ -192,7 +191,7 @@ private Map<String, Set<ClickthroughRate>> getClickthroughRate(final int maxRank
* },
* {
* "term": {
* "action_name": "view"
* "action_name": "impression"
* }
* }
* ],
Expand All @@ -219,7 +218,7 @@ private Map<String, Set<ClickthroughRate>> getClickthroughRate(final int maxRank
" },\n" +
" {\n" +
" \"term\": {\n" +
" \"action_name\": \"view\"\n" +
" \"action_name\": \"impression\"\n" +
" }\n" +
" }\n" +
" ],\n" +
Expand Down Expand Up @@ -355,8 +354,8 @@ public Map<Integer, Double> getRankAggregatedClickThrough() throws Exception {

}

// Handle the "view" bucket.
if(EVENT_VIEW.equalsIgnoreCase(actionBucket.getKey().toString())) {
// Handle the "impression" bucket.
if(EVENT_IMPRESSION.equalsIgnoreCase(actionBucket.getKey().toString())) {

final Terms positionTerms = actionBucket.getAggregations().get("By_Position");
final Collection<? extends Terms.Bucket> positionBuckets = positionTerms.getBuckets();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu
// Get all query IDs matching this user query.
final Collection<String> queryIds = getQueryIdsHavingUserQuery(userQuery);

// For each query ID, get the events with action_name = "view" having a match on objectId and rank (position).
// For each query ID, get the events with action_name = "impression" having a match on objectId and rank (position).
for(final String queryId : queryIds) {

//LOGGER.info("userQuery = {}; queryId = {}; objectId = {}; rank = {}", userQuery, queryId, objectId, rank);
Expand All @@ -160,7 +160,7 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu
" },\n" +
" {\n" +
" \"term\": {\n" +
" \"action_name\": \"view\"\n" +
" \"action_name\": \"impression\"\n" +
" }\n" +
" },\n" +
" {\n" +
Expand Down Expand Up @@ -204,7 +204,10 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu

//LOGGER.info("Query ID: {} --- Count of {} having {} at rank {} = {}", queryId, userQuery, objectId, rank, response.getHits().getTotalHits().value);

countOfTimesShownAtRank += response.getHits().getTotalHits().value;
// Won't be null as long as trackTotalHits is true.
if(response.getHits().getTotalHits() != null) {
countOfTimesShownAtRank += response.getHits().getTotalHits().value;
}

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public final Collection<Map<String, Long>> getQuerySet(final String querySetId)
LOGGER.error("Unable to get query set with ID {}", querySetId);

// The query set was not found.
throw new RuntimeException("The query set with ID " + querySetId + " was not found.");
throw new RuntimeException("The query set with ID " + querySetId + " was not found.");

}

Expand Down
Loading