diff options
author | karowan <karowan55@gmail.com> | 2021-02-05 01:35:34 -0800 |
---|---|---|
committer | karowan <karowan55@gmail.com> | 2021-02-05 01:35:34 -0800 |
commit | 67e513287335875dc1b1e1cd30f3c18687ddea35 (patch) | |
tree | d3ba1ef9feb02728b50c4abec1aabadbf0f5c7ec /container-search | |
parent | 7221ea4b2edc54688f4a89eb4095fecef4be68cd (diff) |
updated documentation
Diffstat (limited to 'container-search')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java b/container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java index 00c0db773d3..647780fa676 100644 --- a/container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java +++ b/container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java @@ -7,6 +7,10 @@ import com.yahoo.search.Result; import com.yahoo.search.Searcher; import com.yahoo.search.searchchain.Execution; +/** + * Recursively replaces all instances of OrItems with WeakAndItems if the query property weakand.replace is true. + * Otherwise a noop searcher + */ public class WeakAndReplacementSearcher extends Searcher { private static final CompoundName WEAKAND_REPLACE = new CompoundName("weakand.replace"); @@ -18,12 +22,23 @@ public class WeakAndReplacementSearcher extends Searcher { return execution.search(query); } + /** + * Extracts the queryTree root and the wand.hits property to send to the recursive replacement function + * @param query the search query + */ private void replaceOrItems(Query query) { Item root = query.getModel().getQueryTree().getRoot(); int hits = query.properties().getInteger("wand.hits", WeakAndItem.defaultN); query.getModel().getQueryTree().setRoot(replaceOrItems(root, hits)); } + + /** + * Recursively iterates over an Item to replace all instances of OrItems with WeakAndItems + * @param item the current item in the replacement iteration + * @param hits the wand.hits property from the request which is assigned to the N value of the new WeakAndItem + * @return The original item or a WeakAndItem replacement of an OrItem + */ private Item replaceOrItems(Item item, int hits) { if (!(item instanceof CompositeItem)) { return item; |