Skip to content

Commit

Permalink
Trimming down logging.
Browse files Browse the repository at this point in the history
Signed-off-by: jzonthemtn <[email protected]>
  • Loading branch information
jzonthemtn committed Dec 10, 2024
1 parent ae5297e commit 15f9253
Show file tree
Hide file tree
Showing 8 changed files with 7 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ public void onResponse(final IndicesExistsResponse indicesExistsResponse) {
client.admin().indices().create(createIndexRequest, new ActionListener<>() {
@Override
public void onResponse(CreateIndexResponse createIndexResponse) {
LOGGER.info("Judgments index created: {}", JUDGMENTS_INDEX_NAME);
LOGGER.debug("Judgments index created: {}", JUDGMENTS_INDEX_NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -382,9 +382,7 @@ private void showClickthroughRates(final Map<String, Set<ClickthroughRate>> clic
LOGGER.info("user_query: {}", userQuery);

for(final ClickthroughRate clickthroughRate : clickthroughRates.get(userQuery)) {

LOGGER.info("\t - {}", clickthroughRate.toString());

}

}
Expand All @@ -394,9 +392,7 @@ private void showClickthroughRates(final Map<String, Set<ClickthroughRate>> clic
private void showRankAggregatedClickThrough(final Map<Integer, Double> rankAggregatedClickThrough) {

for(final int position : rankAggregatedClickThrough.keySet()) {

LOGGER.info("Position: {}, # ctr: {}", position, MathUtils.round(rankAggregatedClickThrough.get(position), parameters.getRoundingDigits()));

}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,6 @@ public UbiQuery getQueryFromQueryId(final String queryId) throws Exception {
if(response.getHits().getHits() != null & response.getHits().getHits().length > 0) {

final SearchHit hit = response.getHits().getHits()[0];

//LOGGER.info("Retrieved query from query ID {}", queryId);
return AccessController.doPrivileged((PrivilegedAction<UbiQuery>) () -> gson.fromJson(hit.getSourceAsString(), UbiQuery.class));

} else {
Expand Down Expand Up @@ -165,8 +163,6 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu
// 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);

final String query = "{\n" +
" \"bool\": {\n" +
" \"must\": [\n" +
Expand Down Expand Up @@ -194,9 +190,6 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu
" }\n" +
" }";

//LOGGER.info(query);
//LOGGER.info("----------------------------------------------------");

final WrapperQueryBuilder qb = QueryBuilders.wrapperQuery(query);

final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
Expand All @@ -209,61 +202,21 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu
final SearchRequest searchRequest = new SearchRequest(indexes, searchSourceBuilder);
final SearchResponse response = client.search(searchRequest).get();

// if(queryId.equals("a2151d8c-44b6-4af6-9993-39cd7798671b")) {
// if(objectId.equals("B07R1J8TYC")) {
// if(rank == 4) {
// LOGGER.info("This is the one!");
// LOGGER.info("Hits = {}", response.getHits().getTotalHits().value);
// LOGGER.info(response.toString());
// }
// }
// }

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

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

}

//LOGGER.info("Count of {} having {} at rank {} = {}", userQuery, objectId, rank, countOfTimesShownAtRank);
LOGGER.debug("Count of {} having {} at rank {} = {}", userQuery, objectId, rank, countOfTimesShownAtRank);

if(countOfTimesShownAtRank > 0) {
//LOGGER.info("Count of {} having {} at rank {} = {}", userQuery, objectId, rank, countOfTimesShownAtRank);
LOGGER.debug("Count of {} having {} at rank {} = {}", userQuery, objectId, rank, countOfTimesShownAtRank);
}

return countOfTimesShownAtRank;

/*
// This commented block was used to get the value using the ubi_queries index.
// We can now just use the ubi_events index.
final String query = "{\"match\": {\"user_query\": \"" + userQuery + "\" }}";
final WrapperQueryBuilder qb = QueryBuilders.wrapperQuery(query);
final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(qb);
final String[] indexes = {INDEX_UBI_QUERIES};
final SearchRequest searchRequest = new SearchRequest(indexes, searchSourceBuilder);
final SearchResponse response = client.search(searchRequest).get();
for(final SearchHit searchHit : response.getHits().getHits()) {
final List<String> queryResponseHidsIds = (List<String>) searchHit.getSourceAsMap().get("query_response_hit_ids");
if(queryResponseHidsIds.get(rank).equals(objectId)) {
countOfTimesShownAtRank++;
}
}
*/

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ protected double calculateDcg(final List<Double> relevanceScores) {
final double numerator = Math.pow(2, relevanceScore) - 1.0;
final double denominator = Math.log(i) / Math.log(i + 2);

LOGGER.info("numerator = {}, denominator = {}", numerator, denominator);
LOGGER.debug("numerator = {}, denominator = {}", numerator, denominator);
dcg += (numerator / denominator);

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,6 @@ public Double getJudgmentValue(final String judgmentsId, final String query, fin
// TODO: Why does this not exist in some cases?
if(j.containsKey("judgment")) {
judgment = (Double) j.get("judgment");

if(judgment > 0) {
LOGGER.info("Found a nonzero judgment! = {}, {}", judgment, query);
}

}

} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void onResponse(final SearchResponse searchResponse) {
queryResults.add(new QueryResult(userQuery, orderedDocumentIds, k, searchMetrics));

} catch (Exception ex) {
LOGGER.error("Unable to get relevance scores.", ex);
LOGGER.error("Unable to get relevance scores for judgments {} and user query {}.", judgmentsId, userQuery, ex);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public void onResponse(IndexResponse indexResponse) {
}

@Override
public void onFailure(Exception e) {
LOGGER.error("Unable to index query set {}", querySetId, e);
public void onFailure(Exception ex) {
LOGGER.error("Unable to index query set {}", querySetId, ex);
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,12 @@ public String sample() throws Exception {

final SearchResponse searchResponse = client.search(searchRequest).get();

// LOGGER.info("Found {} user queries from the ubi_queries index.", searchResponse.getHits().getTotalHits().toString());

final Map<String, Long> queries = new HashMap<>();
for(final SearchHit hit : searchResponse.getHits().getHits()) {
final Map<String, Object> fields = hit.getSourceAsMap();
queries.merge(fields.get("user_query").toString(), 1L, Long::sum);
}

// LOGGER.info("Found {} user queries from the ubi_queries index.", queries.size());

return indexQuerySet(client, parameters.getName(), parameters.getDescription(), parameters.getSampling(), queries);

}
Expand Down

0 comments on commit 15f9253

Please sign in to comment.