diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-05-20 13:53:37 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-05-20 13:53:37 +0200 |
commit | 5d86a48ada45c73fc28b733dd8ed0b3ee50f9663 (patch) | |
tree | f8efbd97e23ecf165375f18a40b5a3f07ea0a84f /container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java | |
parent | e3e9c7536295537e2a9c9c430e6a0f1cda76baca (diff) |
Test searching for backslash
Diffstat (limited to 'container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java')
-rw-r--r-- | container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java | 34 |
1 files changed, 30 insertions, 4 deletions
diff --git a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java index 531167bb342..18fad47de37 100644 --- a/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java +++ b/container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java @@ -2,8 +2,10 @@ package com.yahoo.search.yql; import com.yahoo.component.Version; +import com.yahoo.component.chain.Chain; import com.yahoo.container.QrSearchersConfig; import com.yahoo.language.Language; +import com.yahoo.language.simple.SimpleLinguistics; import com.yahoo.prelude.IndexFacts; import com.yahoo.prelude.IndexModel; import com.yahoo.prelude.query.AndItem; @@ -25,6 +27,7 @@ import com.yahoo.prelude.query.WordAlternativesItem; import com.yahoo.prelude.query.WordItem; import com.yahoo.prelude.querytransform.QueryRewrite; import com.yahoo.search.Query; +import com.yahoo.search.Searcher; import com.yahoo.search.config.IndexInfoConfig; import com.yahoo.search.config.IndexInfoConfig.Indexinfo; import com.yahoo.search.config.IndexInfoConfig.Indexinfo.Alias; @@ -38,6 +41,7 @@ import com.yahoo.search.query.Sorting.UcaSorter; import com.yahoo.search.query.parser.Parsable; import com.yahoo.search.query.parser.ParserEnvironment; +import com.yahoo.search.searchchain.Execution; import org.junit.Test; import java.util.ArrayList; @@ -906,6 +910,30 @@ public class YqlParserTestCase { assertEquals("foo:\"forest WORD_ALTERNATIVES foo:[ tree(0.7) trees(1.0) ]\"", root.toString()); } + /** Verifies that we can search for a backslash */ + @Test + public void testBackslash() { + { + String queryString = "select * from testtype where title contains \"\\\\\";"; // Java escaping * YQL escaping + + QueryTree query = parse(queryString); + + assertEquals("title:\\", query.toString()); + } + + { + Query query = new Query("search?yql=select%20*%20from%20testtype%20where%20title%20contains%20%22%5C%5C%22;"); + + // Cause parsing :-\ + Chain<Searcher> searchChain = new Chain<>(new MinimalQueryInserter()); + Execution.Context context = Execution.Context.createContextStub(null, null, new SimpleLinguistics()); + Execution execution = new Execution(searchChain, context); + execution.search(query); + + assertEquals("title:\\", query.getModel().getQueryTree().toString()); + } + } + private void checkWordAlternativesContent(WordAlternativesItem alternatives) { boolean seenTree = false; boolean seenForest = false; @@ -981,10 +1009,8 @@ public class YqlParserTestCase { private static String toString(List<VespaGroupingStep> steps) { List<String> actual = new ArrayList<>(steps.size()); - for (VespaGroupingStep step : steps) { - actual.add(step.continuations().toString() + - step.getOperation()); - } + for (VespaGroupingStep step : steps) + actual.add(step.continuations().toString() + step.getOperation()); return actual.toString(); } } |