Skip to content

Change model for Judgment entity #77

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

Conversation

martin-gaievski
Copy link
Member

@martin-gaievski martin-gaievski commented Jun 8, 2025

Description

Changed the model for Judgments to use fixed set of fields instead of dynamic field for each query text. Example of Judgment object with new model:

{
  "name": "ESCI Judgments",
  "description": "Judgments generated outside SRW",
  "type": "IMPORT_JUDGMENT",
  "judgmentScores": [
    { "query": "t towels kitchen",
       "ratings": [
      { "docId": "B07NCQWCQS", "score": "100.000" },
      { "docId": "B07NPC54DK", "score": "100.000" },
     ...
      ]
    },
    { "query": " adf":,
      "ratings": [
       { "docId": "B07NCQWCQS", "score": "100.000" },
       { "docId": "B07NPC54DK", "score": "100.000" },
     ...
    ]
   }
    ...
  ]
}

In this PR following items got changed:

  • model and Dao
  • DTO objects for API internal method calls
  • demo script
  • added integ test, adjusted existing unit tests

Issues Resolved

#71

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Martin Gaievski <[email protected]>
@martin-gaievski martin-gaievski force-pushed the changed_model_for_judgments branch from 35c5546 to efa8af2 Compare June 8, 2025 04:14
@martin-gaievski martin-gaievski changed the title Changing model for Judgment entity Change model for Judgment entity Jun 8, 2025
Copy link
Collaborator

@heemin32 heemin32 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks! Could you please remove the commented-out old code?

for (Map.Entry<String, Object> queryEntry : sourceJudgementRatings.entrySet()) {
String queryText = queryEntry.getKey();
Object ratingData = queryEntry.getValue();
// for (Map.Entry<String, Object> queryEntry : sourceJudgementRatings.entrySet()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// for (Map.Entry<String, Object> queryEntry : sourceJudgementRatings.entrySet()) {

) {
Map<String, List<String>> indexAndQueries = (Map<String, List<String>>) results.get(METRICS_INDEX_AND_QUERIES_FIELD_NAME);
List<String> queryTextWithReferences = (List<String>) results.get(METRICS_QUERY_TEXT_FIELD_NAME);

Map<String, Map<String, String>> allJudgments = new HashMap<>();
// Map<String, Map<String, String>> allJudgments = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Map<String, Map<String, String>> allJudgments = new HashMap<>();

@Override
public void onResponse(Map<String, String> docIdToScore) {
synchronized (allJudgments) {
allJudgments.put(queryTextWithReference, docIdToScore);
// allJudgments.put(queryTextWithReference, docIdToScore);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// allJudgments.put(queryTextWithReference, docIdToScore);

) {
LOGGER.debug("Starting COEC calculation with rank CTR: {}", rankAggregatedClickThrough);
Map<String, Map<String, String>> judgmentRatings = new HashMap<>();
// Map<String, Map<String, String>> judgmentRatings = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Map<String, Map<String, String>> judgmentRatings = new HashMap<>();

}
LOGGER.debug(
"Final judgment ratings size - Queries: {}, Total Documents: {}",
judgmentRatings.size(),
judgmentRatings.values().stream().mapToInt(Map::size).sum()
// judgmentRatings.values().stream().mapToInt(Map::size).sum()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// judgmentRatings.values().stream().mapToInt(Map::size).sum()

}

@Override
public void writeTo(StreamOutput out) throws IOException {
super.writeTo(out);
out.writeMap(judgmentScores);
// out.writeList(judgmentScores);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// out.writeList(judgmentScores);

Signed-off-by: Martin Gaievski <[email protected]>
@martin-gaievski
Copy link
Member Author

Looks good to me, thanks! Could you please remove the commented-out old code?

corrected, thanks @heemin32

@martin-gaievski martin-gaievski merged commit 8263dc4 into opensearch-project:main Jun 8, 2025
15 checks passed
Copy link

codecov bot commented Jun 8, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 0.00%. Comparing base (5492261) to head (eb4c80f).
Report is 1 commits behind head on main.

Additional details and impacted files
@@    Coverage Diff     @@
##   main   #77   +/-   ##
==========================
==========================

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

wrigleyDan added a commit to wrigleyDan/search-relevance that referenced this pull request Jun 10, 2025
wrigleyDan added a commit that referenced this pull request Jun 10, 2025
* fix implicit judgment for the new nested data structure introduced in #77

Signed-off-by: wrigleyDan <[email protected]>

* run ./gradlew spotlessApply

Signed-off-by: wrigleyDan <[email protected]>

* add entry to CHANGELOG.md

Signed-off-by: wrigleyDan <[email protected]>

* edit comment as per suggestion

Signed-off-by: wrigleyDan <[email protected]>

---------

Signed-off-by: wrigleyDan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants