diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-04-26 15:40:34 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-04-26 15:40:34 +0200 |
commit | 333fd9d87825a6e7630291f1606938bd721d8861 (patch) | |
tree | a96e9a8c2c249bd61e6dc3e0511e52aa7301747d /container-search | |
parent | 5f6a5a5d626808459bc65c95eb226e746ed3d18f (diff) |
Mark phrases as explicit
Diffstat (limited to 'container-search')
3 files changed, 12 insertions, 23 deletions
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 e44a86ddd2d..d7aec40bcf9 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 @@ -48,18 +48,12 @@ public class PhraseItem extends CompositeIndexedItem { } } - /** - * Sets whether this was explicitly written as a phrase using quotes by the - * user - */ + /** Sets whether this was explicitly written as a phrase using quotes by the user */ public void setExplicit(boolean explicit) { this.explicit = explicit; } - /** - * Returns whether this was explicitly written as a phrase using quotes by - * the user Default is false - */ + /** Returns whether this was explicitly written as a phrase using quotes by the user Default is false */ public boolean isExplicit() { return explicit; } @@ -74,8 +68,7 @@ public class PhraseItem extends CompositeIndexedItem { * this phrase. If the item is a word, it will simply be added, if the item * is a phrase, each of the words of the phrase will be added. * - * @throws IllegalArgumentException - * if the given item is not a WordItem or PhraseItem + * @throws IllegalArgumentException if the given item is not a WordItem or PhraseItem */ public void addItem(Item item) { if (item instanceof WordItem || item instanceof PhraseSegmentItem || item instanceof WordAlternativesItem) { @@ -89,8 +82,7 @@ public class PhraseItem extends CompositeIndexedItem { addIndexedItem((IndexedItem) i.next()); } } else { - throw new IllegalArgumentException("Can not add " + item - + " to a phrase"); + throw new IllegalArgumentException("Can not add " + item + " to a phrase"); } } @@ -107,8 +99,7 @@ public class PhraseItem extends CompositeIndexedItem { addIndexedItem(index++, (WordItem) i.next()); } } else { - throw new IllegalArgumentException("Can not add " + item - + " to a phrase"); + throw new IllegalArgumentException("Can not add " + item + " to a phrase"); } } @@ -130,8 +121,7 @@ public class PhraseItem extends CompositeIndexedItem { } return toReturn; } else { - throw new IllegalArgumentException("Can not add " + item - + " to a phrase"); + throw new IllegalArgumentException("Can not add " + item + " to a phrase"); } } @@ -153,10 +143,8 @@ public class PhraseItem extends CompositeIndexedItem { /** * Returns a subitem as a word item * - * @param index - * the (0-base) index of the item to return - * @throws IndexOutOfBoundsException - * if there is no subitem at index + * @param index the (0-base) index of the item to return + * @throws IndexOutOfBoundsException if there is no subitem at index */ public WordItem getWordItem(int index) { return (WordItem) getItem(index); @@ -197,9 +185,7 @@ public class PhraseItem extends CompositeIndexedItem { return itemCount; } - /** - * Returns false, no parenthezes for phrases - */ + /** Returns false, no parenthezes for phrases */ protected boolean shouldParenthize() { return false; } @@ -263,4 +249,5 @@ public class PhraseItem extends CompositeIndexedItem { super.disclose(discloser); discloser.addProperty("explicit", explicit); } + } diff --git a/container-search/src/main/java/com/yahoo/search/query/SelectParser.java b/container-search/src/main/java/com/yahoo/search/query/SelectParser.java index 18e4cdb35d6..ae1d82ef0fb 100644 --- a/container-search/src/main/java/com/yahoo/search/query/SelectParser.java +++ b/container-search/src/main/java/com/yahoo/search/query/SelectParser.java @@ -976,6 +976,7 @@ public class SelectParser implements Parser { PhraseItem phrase = new PhraseItem(); phrase.setIndexName(field); + phrase.setExplicit(true); HashMap<Integer, Inspector> children = childMap(value); for (Inspector word : children.values()) { diff --git a/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java b/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java index 3eac1d88784..45fdc4653c4 100644 --- a/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java +++ b/container-search/src/main/java/com/yahoo/search/yql/YqlParser.java @@ -539,6 +539,7 @@ public class YqlParser implements Parser { PhraseItem phrase = new PhraseItem(); phrase.setIndexName(field); + phrase.setExplicit(true); for (OperatorNode<ExpressionOperator> word : ast.<List<OperatorNode<ExpressionOperator>>> getArgument(1)) { if (word.getOperator() == ExpressionOperator.CALL) { List<String> names = word.getArgument(0); |