diff options
author | Harald Musum <musum@yahooinc.com> | 2023-06-06 16:18:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-06 16:18:29 +0200 |
commit | 875018f7acb1bbd9f186b97d177be296ff157ba7 (patch) | |
tree | 1ec11fe8a82b14ab7f1adb025b067f5d3208ccaa /container-search/src/test/java/com/yahoo | |
parent | 1f29e0a0d025c25ef97db01d0e2b66390a29204e (diff) |
Revert "Validate prefix matching"
Diffstat (limited to 'container-search/src/test/java/com/yahoo')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java | 49 |
1 files changed, 13 insertions, 36 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java b/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java index 8c525b2975a..64fb4354003 100644 --- a/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/searchers/test/QueryValidatorTestCase.java @@ -18,7 +18,7 @@ import static org.junit.jupiter.api.Assertions.fail; public class QueryValidatorTestCase { @Test - void testTensorsCannotBeSearchedForTerms() { + void testValidation() { SearchDefinition sd = new SearchDefinition("test"); sd.addCommand("mytensor1", "type tensor(x[100]"); sd.addCommand("mytensor2", "type tensor<float>(x[100]"); @@ -27,47 +27,24 @@ public class QueryValidatorTestCase { IndexFacts indexFacts = new IndexFacts(model); Execution execution = new Execution(Execution.Context.createContextStub(indexFacts)); - assertSucceeds("?query=mystring:foo", execution); - assertFails("Cannot search for terms in 'mytensor1': It is a tensor field", - "?query=mytensor1:foo", execution); - assertFails("Cannot search for terms in 'mytensor2': It is a tensor field", - "?query=mytensor2:foo", execution); - } - - @Test - void testPrefixRequiresAttribute() { - SearchDefinition sd = new SearchDefinition("test"); - sd.addCommand("attributeOnly", "type string") - .addCommand("attribute"); - sd.addCommand("indexOnly", "type string") - .addCommand("index"); - sd.addCommand("attributeAndIndex", "type string") - .addCommand("attribute") - .addCommand("index"); - IndexModel model = new IndexModel(sd); - - IndexFacts indexFacts = new IndexFacts(model); - Execution execution = new Execution(Execution.Context.createContextStub(indexFacts)); + new QueryValidator().search(new Query("?query=mystring:foo"), execution); - assertSucceeds("?query=attributeOnly:foo*", execution); - assertFails("'indexOnly' is not an attribute field: Prefix matching is not supported", - "?query=indexOnly:foo*", execution); - assertFails("'attributeAndIndex' is an index field: Prefix matching is not supported even when it is also an attribute", - "?query=attributeAndIndex:foo*", execution); - } - - private void assertSucceeds(String query, Execution execution) { - new QueryValidator().search(new Query(query), execution); - } + try { + new QueryValidator().search(new Query("?query=mytensor1:foo"), execution); + fail("Expected validation error"); + } + catch (IllegalArgumentException e) { + // success + assertEquals("Cannot search 'mytensor1': It is a tensor field", e.getMessage()); + } - private void assertFails(String expectedError, String query, Execution execution) { try { - new QueryValidator().search(new Query(query), execution); - fail("Expected validation error from " + query); + new QueryValidator().search(new Query("?query=mytensor2:foo"), execution); + fail("Expected validation error"); } catch (IllegalArgumentException e) { // success - assertEquals(expectedError, e.getMessage()); + assertEquals("Cannot search 'mytensor2': It is a tensor field", e.getMessage()); } } |