Skip to content

Commit

Permalink
Merge pull request #54 from o19s/ordinal
Browse files Browse the repository at this point in the history
Renaming position index to ordinal
  • Loading branch information
wrigleyDan authored Dec 9, 2024
2 parents dcbdfbd + 8cd1449 commit 49c4522
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions data/ubi-chorus-data-generator/ubi_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"description": query_response["hits"]["hits"][random_search_result_index]["_source"][item_description_field]
},
"position": {
"index": random_search_result_index
"ordinal": random_search_result_index
},
"session_id": session_id
}
Expand Down Expand Up @@ -113,7 +113,7 @@
"description": query_response["hits"]["hits"][random_search_result_index]["_source"][item_description_field]
},
"position": {
"index": random_search_result_index
"ordinal": random_search_result_index
},
"session_id": session_id
}
Expand Down
2 changes: 1 addition & 1 deletion opensearch-search-quality-evaluation-plugin/aggs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ curl -X GET http://localhost:9200/ubi_events/_search -H "Content-Type: applicati
"aggs": {
"By_Position": {
"terms": {
"field": "event_attributes.position.index"
"field": "event_attributes.position.ordinal"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ private Map<String, Set<ClickthroughRate>> getClickthroughRate(final int maxRank
* "must": [
* {
* "range": {
* "event_attributes.position.index": {
* "event_attributes.position.ordinal": {
* "lte": 20
* }
* }
Expand All @@ -225,7 +225,7 @@ private Map<String, Set<ClickthroughRate>> getClickthroughRate(final int maxRank
" \"must\": [\n" +
" {\n" +
" \"range\": {\n" +
" \"event_attributes.position.index\": {\n" +
" \"event_attributes.position.ordinal\": {\n" +
" \"lte\": 20\n" +
" }\n" +
" }\n" +
Expand Down Expand Up @@ -319,10 +319,10 @@ public Map<Integer, Double> getRankAggregatedClickThrough() throws Exception {

// TODO: Allow for a time period and for a specific application.

final QueryBuilder findRangeNumber = QueryBuilders.rangeQuery("event_attributes.position.index").lte(parameters.getMaxRank());
final QueryBuilder findRangeNumber = QueryBuilders.rangeQuery("event_attributes.position.ordinal").lte(parameters.getMaxRank());
final QueryBuilder queryBuilder = new BoolQueryBuilder().must(findRangeNumber);

final TermsAggregationBuilder positionsAggregator = AggregationBuilders.terms("By_Position").field("event_attributes.position.index").size(parameters.getMaxRank());
final TermsAggregationBuilder positionsAggregator = AggregationBuilders.terms("By_Position").field("event_attributes.position.ordinal").size(parameters.getMaxRank());
final TermsAggregationBuilder actionNameAggregation = AggregationBuilders.terms("By_Action").field("action_name").subAggregation(positionsAggregator).size(parameters.getMaxRank());

final SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,28 +15,28 @@
*/
public class Position {

@SerializedName("index")
private int index;
@SerializedName("ordinal")
private int ordinal;

@Override
public String toString() {
return String.valueOf(index);
return String.valueOf(ordinal);
}

/**
* Gets the index of the position.
* @return The index of the position.
* Gets the ordinal of the position.
* @return The ordinal of the position.
*/
public int getIndex() {
return index;
public int getOrdinal() {
return ordinal;
}

/**
* Sets the index of the position.
* @param index The index of the position.
* Sets the ordinal of the position.
* @param ordinal The ordinal of the position.
*/
public void setIndex(int index) {
this.index = index;
public void setOrdinal(int ordinal) {
this.ordinal = ordinal;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public UbiEvent() {

@Override
public String toString() {
return actionName + ", " + clientId + ", " + queryId + ", " + eventAttributes.getObject().toString() + ", " + eventAttributes.getPosition().getIndex();
return actionName + ", " + clientId + ", " + queryId + ", " + eventAttributes.getObject().toString() + ", " + eventAttributes.getPosition().getOrdinal();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public long getCountOfQueriesForUserQueryHavingResultInRankR(final String userQu
" },\n" +
" {\n" +
" \"term\": {\n" +
" \"event_attributes.position.index\": \"" + rank + "\"\n" +
" \"event_attributes.position.ordinal\": \"" + rank + "\"\n" +
" }\n" +
" },\n" +
" {\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ GET ubi_events/_search
{
"query": {
"range": {
"event_attributes.position.index": {
"event_attributes.position.ordinal": {
"lte": 20
}
}
Expand Down Expand Up @@ -115,7 +115,7 @@ GET ubi_events/_search
},
{
"term": {
"event_attributes.position.index": "0"
"event_attributes.position.ordinal": "0"
}
},
{
Expand All @@ -141,7 +141,7 @@ GET ubi_events/_search
"aggs": {
"By_Position": {
"terms": {
"field": "event_attributes.position.index",
"field": "event_attributes.position.ordinal",
"size": 20
}
}
Expand Down

0 comments on commit 49c4522

Please sign in to comment.