aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/querytransform
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-08-12 14:49:08 +0200
committerHenning Baldersheim <balder@yahoo-inc.com>2022-08-12 14:49:08 +0200
commit36b70fc6681a80d8debcefb4e50aa8fd9d33bb46 (patch)
treea91cc3f122cababb89c69a3f1bc7ad4059712e32 /container-search/src/main/java/com/yahoo/search/querytransform
parente1c3e2f3c11360702c378bf85caf61f1258c8c53 (diff)
- Use CompoundName where possible.
- Avoid * imports. - Use common property definition.
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/querytransform')
-rw-r--r--container-search/src/main/java/com/yahoo/search/querytransform/WeakAndReplacementSearcher.java13
1 files changed, 8 insertions, 5 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 b47b54bc362..898e348db92 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
@@ -1,7 +1,10 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.search.querytransform;
-import com.yahoo.prelude.query.*;
+import com.yahoo.prelude.query.CompositeItem;
+import com.yahoo.prelude.query.Item;
+import com.yahoo.prelude.query.OrItem;
+import com.yahoo.prelude.query.WeakAndItem;
import com.yahoo.processing.request.CompoundName;
import com.yahoo.search.Query;
import com.yahoo.search.Result;
@@ -15,7 +18,8 @@ import com.yahoo.search.searchchain.Execution;
* @author karowan
*/
public class WeakAndReplacementSearcher extends Searcher {
- private static final CompoundName WEAKAND_REPLACE = new CompoundName("weakAnd.replace");
+ static final CompoundName WEAKAND_REPLACE = new CompoundName("weakAnd.replace");
+ static final CompoundName WAND_HITS = new CompoundName("wand.hits");
@Override public Result search(Query query, Execution execution) {
if (!query.properties().getBoolean(WEAKAND_REPLACE)) {
@@ -31,7 +35,7 @@ public class WeakAndReplacementSearcher extends Searcher {
*/
private void replaceOrItems(Query query) {
Item root = query.getModel().getQueryTree().getRoot();
- int hits = query.properties().getInteger("wand.hits", WeakAndItem.defaultN);
+ int hits = query.properties().getInteger(WAND_HITS, WeakAndItem.defaultN);
query.getModel().getQueryTree().setRoot(replaceOrItems(root, hits));
if (root != query.getModel().getQueryTree().getRoot())
query.trace("Replaced OR by WeakAnd", true, 2);
@@ -45,10 +49,9 @@ public class WeakAndReplacementSearcher extends Searcher {
* @return the original item or a WeakAndItem replacement of an OrItem
*/
private Item replaceOrItems(Item item, int hits) {
- if (!(item instanceof CompositeItem)) {
+ if (!(item instanceof CompositeItem compositeItem)) {
return item;
}
- CompositeItem compositeItem = (CompositeItem) item;
if (compositeItem instanceof OrItem) {
WeakAndItem newItem = new WeakAndItem(hits);
newItem.setWeight(compositeItem.getWeight());