Search in sources :

Example 1 with YqlParser

use of com.yahoo.search.yql.YqlParser in project vespa by vespa-engine.

the class GroupingParserTestCase method assertYqlParsable.

private static void assertYqlParsable(String request, String... expectedOperations) {
    YqlParser parser = new YqlParser(new ParserEnvironment());
    parser.parse(new Parsable().setQuery("select foo from bar where baz contains 'baz' | " + request + ";"));
    List<VespaGroupingStep> steps = parser.getGroupingSteps();
    List<String> actual = new ArrayList<>(steps.size());
    for (VespaGroupingStep step : steps) {
        actual.add(step.getOperation().toString());
    }
    if (expectedOperations.length > 0) {
        assertEquals(Arrays.asList(expectedOperations), actual);
    }
}
Also used : YqlParser(com.yahoo.search.yql.YqlParser) VespaGroupingStep(com.yahoo.search.yql.VespaGroupingStep) ArrayList(java.util.ArrayList) Parsable(com.yahoo.search.query.parser.Parsable) ParserEnvironment(com.yahoo.search.query.parser.ParserEnvironment)

Example 2 with YqlParser

use of com.yahoo.search.yql.YqlParser in project vespa by vespa-engine.

the class ValidatePredicateSearcherTestCase method doSearch.

private static Result doSearch(ValidatePredicateSearcher searcher, String yqlQuery, String command) {
    QueryTree queryTree = new YqlParser(new ParserEnvironment()).parse(new Parsable().setQuery(yqlQuery));
    Query query = new Query();
    query.getModel().getQueryTree().setRoot(queryTree.getRoot());
    TreeMap<String, List<String>> masterClusters = new TreeMap<>();
    masterClusters.put("cluster", Arrays.asList("document"));
    SearchDefinition searchDefinition = new SearchDefinition("document");
    Index index = new Index("predicate_field");
    index.addCommand(command);
    searchDefinition.addIndex(index);
    Map<String, SearchDefinition> searchDefinitionMap = new HashMap<>();
    searchDefinitionMap.put("document", searchDefinition);
    IndexFacts indexFacts = new IndexFacts(new IndexModel(masterClusters, searchDefinitionMap, searchDefinition));
    Execution.Context context = new Execution.Context(null, indexFacts, null, new RendererRegistry(MoreExecutors.directExecutor()), new SimpleLinguistics());
    return new Execution(searcher, context).search(query);
}
Also used : Query(com.yahoo.search.Query) IndexFacts(com.yahoo.prelude.IndexFacts) Parsable(com.yahoo.search.query.parser.Parsable) Index(com.yahoo.prelude.Index) IndexModel(com.yahoo.prelude.IndexModel) SearchDefinition(com.yahoo.prelude.SearchDefinition) SimpleLinguistics(com.yahoo.language.simple.SimpleLinguistics) YqlParser(com.yahoo.search.yql.YqlParser) Execution(com.yahoo.search.searchchain.Execution) QueryTree(com.yahoo.search.query.QueryTree) RendererRegistry(com.yahoo.search.rendering.RendererRegistry) ParserEnvironment(com.yahoo.search.query.parser.ParserEnvironment)

Aggregations

Parsable (com.yahoo.search.query.parser.Parsable)2 ParserEnvironment (com.yahoo.search.query.parser.ParserEnvironment)2 YqlParser (com.yahoo.search.yql.YqlParser)2 SimpleLinguistics (com.yahoo.language.simple.SimpleLinguistics)1 Index (com.yahoo.prelude.Index)1 IndexFacts (com.yahoo.prelude.IndexFacts)1 IndexModel (com.yahoo.prelude.IndexModel)1 SearchDefinition (com.yahoo.prelude.SearchDefinition)1 Query (com.yahoo.search.Query)1 QueryTree (com.yahoo.search.query.QueryTree)1 RendererRegistry (com.yahoo.search.rendering.RendererRegistry)1 Execution (com.yahoo.search.searchchain.Execution)1 VespaGroupingStep (com.yahoo.search.yql.VespaGroupingStep)1 ArrayList (java.util.ArrayList)1