Skip to content

Commit

Permalink
Polishing comments based on javaDoc Task
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Flores <[email protected]>
  • Loading branch information
brianf-aws committed Oct 21, 2024
1 parent 8d6a2c7 commit ae35ddb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,16 @@ public void rescoreSearchResponse(SearchResponse response, Map<String, Object> r
listener.onResponse(scores);
}

/**
* Implements the behavior of the SearchHit validator {@code SearchHitValidator}
* It checks all the following
* <ul>
* <li>Checks the search hit has a source mapping</li>
* <li>Checks that the mapping exists in the source mapping using the target_field</li>
* <li>Checks that the mapping has a numerical score for it to rerank</li>
* </ul>
* @param hit A search hit to validate
*/
public void byFieldSearchHitValidator(SearchHit hit) {
if (!hit.hasSource()) {
throw new IllegalArgumentException("There is no source field to be able to perform rerank on hit [" + hit.docId() + "]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ public static float getScoreFromSourceMap(Map<String, Object> sourceAsMap, Strin
* <hr>
* <b>This method assumes that the path to the mapping exists as checked by {@link #validateRerankCriteria(SearchHit[], SearchHitValidator, ActionListener)}</b>
* As such no error checking is done in the methods implementing this functionality
* <hr>
* You can think of this algorithm as a recursive one the base case is deleting the targetField. The recursive case
* is going to the next map along with the respective key. Along the way if it finds a map is empty it will delete it
* @param sourceAsMap the map of maps that contains the <code>targetField</code>
* @param targetField The path to take to remove the targetField
* @implNote You can think of this algorithm as a recursive one the base case is deleting the targetField. The recursive case
* is going to the next map along with the respective key. Along the way if it finds a map is empty it will delete it
*/
public static void removeTargetFieldFromSource(Map<String, Object> sourceAsMap, String targetField) {
Stack<Tuple<Map<String, Object>, String>> parentMapChildrenKeyTupleStack = new Stack<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.stream.IntStream;

import static org.mockito.Mockito.doReturn;
Expand Down Expand Up @@ -787,7 +786,7 @@ private void setUpValidSearchResultsWithNestedTargetValue() throws IOException {

hits[i] = new SearchHit(docId, docId + "", Collections.emptyMap(), Collections.emptyMap());
hits[i].sourceRef(new BytesArray(sourceMap));
hits[i].score(new Random().nextFloat());
hits[i].score(1);
}

TotalHits totalHits = new TotalHits(sampleIndexMLScorePairs.size(), TotalHits.Relation.EQUAL_TO);
Expand Down Expand Up @@ -826,7 +825,7 @@ private void setUpValidSearchResultsWithNonNestedTargetValueWithDenseSourceMappi

hits[i] = new SearchHit(docId, docId + "", Collections.emptyMap(), Collections.emptyMap());
hits[i].sourceRef(new BytesArray(sourceMap));
hits[i].score(new Random().nextFloat());
hits[i].score(1);
}

TotalHits totalHits = new TotalHits(sampleIndexMLScorePairs.size(), TotalHits.Relation.EQUAL_TO);
Expand Down

0 comments on commit ae35ddb

Please sign in to comment.