aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorArne Juul <arnej@vespa.ai>2024-01-24 13:12:16 +0000
committerArne Juul <arnej@vespa.ai>2024-01-24 13:28:06 +0000
commit2b1b4f5cd9f9ce21f738a4c5ccd50017fc654407 (patch)
tree8a01d7dad59c0164d7394a1be2c0dee7b50a4ca6 /container-search
parent2a43344d217ab065425e880cd35be54542423ce8 (diff)
propagate phrase weight to all contained items
Diffstat (limited to 'container-search')
-rw-r--r--container-search/abi-spec.json1
-rw-r--r--container-search/src/main/java/com/yahoo/prelude/query/PhraseItem.java15
2 files changed, 16 insertions, 0 deletions
diff --git a/container-search/abi-spec.json b/container-search/abi-spec.json
index aedccbee46b..2304743873f 100644
--- a/container-search/abi-spec.json
+++ b/container-search/abi-spec.json
@@ -1154,6 +1154,7 @@
"public void addItem(int, com.yahoo.prelude.query.Item)",
"public com.yahoo.prelude.query.Item setItem(int, com.yahoo.prelude.query.Item)",
"public java.util.Optional extractSingleChild()",
+ "public void setWeight(int)",
"public com.yahoo.prelude.query.WordItem getWordItem(int)",
"public com.yahoo.prelude.query.BlockItem getBlockItem(int)",
"protected void encodeThis(java.nio.ByteBuffer)",
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/PhraseItem.java b/container-search/src/main/java/com/yahoo/prelude/query/PhraseItem.java
index 755e8de5e4f..ff811c97ba4 100644
--- a/container-search/src/main/java/com/yahoo/prelude/query/PhraseItem.java
+++ b/container-search/src/main/java/com/yahoo/prelude/query/PhraseItem.java
@@ -153,14 +153,29 @@ public class PhraseItem extends CompositeIndexedItem {
private void addIndexedItem(int index, IndexedItem word) {
word.setIndexName(this.getIndexName());
+ if (word instanceof Item item) {
+ item.setWeight(this.getWeight());
+ }
super.addItem(index, (Item) word);
}
private Item setIndexedItem(int index, IndexedItem word) {
word.setIndexName(this.getIndexName());
+ if (word instanceof Item item) {
+ item.setWeight(this.getWeight());
+ }
return super.setItem(index, (Item) word);
}
+ @Override
+ public void setWeight(int weight) {
+ super.setWeight(weight);
+ for (Iterator<Item> i = getItemIterator(); i.hasNext();) {
+ Item word = i.next();
+ word.setWeight(weight);
+ }
+ }
+
/**
* Returns a subitem as a word item
*