diff options
Diffstat (limited to 'container-search/src/test')
3 files changed, 22 insertions, 3 deletions
diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java index 13b65716ffc..f83ad354c89 100644 --- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java @@ -24,10 +24,11 @@ public class ExpansionTestCase extends RuleBaseAbstractTestCase { assertSemantics("EQUIV testfield:e1 testfield:e2 testfield:e3", "testfield:foo"); } + // No equiv: Not optimal, but not wrong either @Test void testEquivExpansion3() { assertSemantics("AND testfield:e1 testfield:e2 testfield:e3 testfield:e1 testfield:e2 testfield:e3", - "testfield:foo testfield:bar"); + "testfield:foo testfield:bar"); } } diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java b/container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java index 045d8698547..370ca20e612 100644 --- a/container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java +++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java @@ -15,12 +15,26 @@ public class OrPhraseTestCase extends RuleBaseAbstractTestCase { @Test void testReplacing1() { assertSemantics("OR title:\"software engineer\" (AND new york)", "software engineer new york"); - assertSemantics("title:\"software engineer\"", "software engineer"); // Skip or when there is nothing else + assertSemantics("title:\"software engineer\"", "software engineer"); // Skip OR when there is nothing else } @Test void testReplacing2() { - assertSemantics("OR lotr \"lord of the rings\"", "lotr"); + assertSemantics("OR \"lord of the rings\" lotr", "lotr"); + } + + @Test + void testReplacing2WithFollowingQuery() { + assertSemantics("AND (OR \"lord of the rings\" lotr) is a movie", "lotr is a movie"); + } + + @Test + void testReplacing2WithPrecedingQuery() { + assertSemantics("AND a movie is (OR \"lord of the rings\" lotr)", "a movie is lotr"); + } + @Test + void testReplacing2WithSurroundingQuery() { + assertSemantics("AND a movie is (OR \"lord of the rings\" lotr) yes", "a movie is lotr yes"); } } diff --git a/container-search/src/test/java/com/yahoo/prelude/semantics/test/rulebases/equiv.sr b/container-search/src/test/java/com/yahoo/prelude/semantics/test/rulebases/equiv.sr new file mode 100644 index 00000000000..99102fcd03f --- /dev/null +++ b/container-search/src/test/java/com/yahoo/prelude/semantics/test/rulebases/equiv.sr @@ -0,0 +1,4 @@ +# Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +@default + +lotr +> ="lord of the rings"; |