diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2024-01-24 21:07:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 21:07:50 +0100 |
commit | dd9d5bbf74674e17a17d07734da2513a479e4037 (patch) | |
tree | 3363f9de572dd8181f39702ce4ca6ff7e19c9d8a | |
parent | 126bdc4405385e7b70e1018d1f28e3aaa7e92e60 (diff) | |
parent | 2b1b4f5cd9f9ce21f738a4c5ccd50017fc654407 (diff) |
Merge pull request #30045 from vespa-engine/arnej/distribute-phrase-weight
propagate phrase weight to all contained items
-rw-r--r-- | container-search/abi-spec.json | 1 | ||||
-rw-r--r-- | container-search/src/main/java/com/yahoo/prelude/query/PhraseItem.java | 15 |
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 * |