aboutsummaryrefslogtreecommitdiffstats
path: root/container-search/src/test/java/com/yahoo/prelude
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@vespa.ai>2023-09-08 16:20:47 +0200
committerJon Bratseth <bratseth@vespa.ai>2023-09-08 16:20:47 +0200
commitcbf103929d33dc697cd5fac94adfba36ed501dc9 (patch)
treedeb10b43ce721d4e764a4392e0386ed2ddce1129 /container-search/src/test/java/com/yahoo/prelude
parent4dd974027190e5f378556ebd4816fc1e7ebe7b21 (diff)
Synonym expansions
Diffstat (limited to 'container-search/src/test/java/com/yahoo/prelude')
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/ExpansionTestCase.java3
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/OrPhraseTestCase.java18
-rw-r--r--container-search/src/test/java/com/yahoo/prelude/semantics/test/rulebases/equiv.sr4
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";