aboutsummaryrefslogtreecommitdiffstats
path: root/container-search
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@vespa.ai>2024-01-03 10:09:08 +0100
committerJon Bratseth <bratseth@vespa.ai>2024-01-03 10:09:08 +0100
commit2f6536968f718037662b2903638c93b72ff6dd09 (patch)
treeb7b15fd2a4f9fb14698f21e4f0d73e8d7ecb2e1c /container-search
parent2bd905f66ba3f2f201cfb186f6156193257a40de (diff)
Add test of programmatic parsing
Diffstat (limited to 'container-search')
-rw-r--r--container-search/src/test/java/com/yahoo/search/yql/YqlParserTestCase.java14
1 files changed, 14 insertions, 0 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 783a0ec61de..75e9525f09b 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
@@ -45,8 +45,10 @@ import com.yahoo.search.query.Sorting.LowerCaseSorter;
import com.yahoo.search.query.Sorting.Order;
import com.yahoo.search.query.Sorting.UcaSorter;
import com.yahoo.search.query.parser.Parsable;
+import com.yahoo.search.query.parser.Parser;
import com.yahoo.search.query.parser.ParserEnvironment;
+import com.yahoo.search.query.parser.ParserFactory;
import com.yahoo.search.searchchain.Execution;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
@@ -1210,6 +1212,18 @@ public class YqlParserTestCase {
"and string fields. The fieldset mixed has both"));
}
+ // TODO: Put this in the documentation
+ @Test
+ public void testProgrammaticYqlParsing() {
+ Execution execution = new Execution(Execution.Context.createContextStub());
+ Parser parser = ParserFactory.newInstance(Query.Type.YQL,
+ ParserEnvironment.fromExecutionContext(execution.context()));
+ Query query = new Query();
+ query.getModel().setType(Query.Type.YQL);
+ query.getModel().setQueryString("select * from myDoc where foo contains 'bar' and fuz contains '3'");
+ parser.parse(Parsable.fromQueryModel(query.getModel()));
+ }
+
private static void assertNumericInItem(String field, long[] values, QueryTree query) {
var exp = buildNumericInItem(field, values);
assertEquals(exp, query.getRoot());