diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-04-12 12:54:11 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-04-12 12:54:11 +0200 |
commit | 08be9a163a0861901bd832f2d0cbd1c0d4a05ddf (patch) | |
tree | 0b18706b1e43135fcb10a05b5cf1ad59dae5bc5e /container-search | |
parent | dda32fff6ffc7ffd4dd3686cfd940c0c132085b6 (diff) |
Correct heuristic for -a:b
Diffstat (limited to 'container-search')
3 files changed, 15 insertions, 2 deletions
diff --git a/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java b/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java index 499cacd89c5..72ee4ae2c12 100644 --- a/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java +++ b/container-search/src/main/java/com/yahoo/prelude/query/parser/AllParser.java @@ -127,8 +127,11 @@ public class AllParser extends SimpleParser { // Heuristic overdrive engaged! // Interpret -N as a positive item matching a negative number (by backtracking out of this) + // but not if there is an explicit index (such as -a:b) // but interpret --N as a negative item matching a negative number - if ( item instanceof IntItem && ! ((IntItem)item).getNumber().startsWith(("-"))) + if ( item instanceof IntItem && + ((IntItem)item).getIndexName().isEmpty() && + ! ((IntItem)item).getNumber().startsWith(("-"))) item = null; return item; diff --git a/container-search/src/main/java/com/yahoo/search/searchchain/Execution.java b/container-search/src/main/java/com/yahoo/search/searchchain/Execution.java index 6a56f94c724..5427da6c06c 100644 --- a/container-search/src/main/java/com/yahoo/search/searchchain/Execution.java +++ b/container-search/src/main/java/com/yahoo/search/searchchain/Execution.java @@ -481,7 +481,7 @@ public class Execution extends com.yahoo.processing.execution.Execution { * if searchChain is null */ @SuppressWarnings("unchecked") - private Execution(Chain<? extends Processor> searchChain,Context context, int searcherIndex) { + private Execution(Chain<? extends Processor> searchChain, Context context, int searcherIndex) { // Create a new Execution which is placed in the context of the execution of the given Context if any // "if any" because a context may, or may not, belong to an execution. // This is decided at the creation time of the Context - Context instances which do not belong diff --git a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java index 73f2ae7eb87..dc2f990431a 100644 --- a/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/query/parser/test/ParseTestCase.java @@ -1971,6 +1971,16 @@ public class ParseTestCase { } @Test + public void testNegativeTermPositiveNumberWithIndex() { + tester.assertParsed("+a -normal:12", "a -normal:12", Query.Type.ALL); + } + + @Test + public void testNegativeTermNegativeNumberWithIndex() { + tester.assertParsed("+a -normal:-12", "a -normal:-12", Query.Type.ALL); + } + + @Test public void testSingleNegativeNumberLikeTerm() { tester.assertParsed("-12", "-12", Query.Type.ALL); } |