Search in sources :

Example 6 with NullItem

use of com.yahoo.prelude.query.NullItem in project vespa by vespa-engine.

the class CJKSearcherTestCase method assertTransformed.

private void assertTransformed(String queryString, String expected, Query.Type mode, Language actualLanguage, Language queryLanguage, Linguistics linguistics) {
    Parser parser = ParserFactory.newInstance(mode, new ParserEnvironment().setIndexFacts(indexFacts).setLinguistics(linguistics));
    Item root = parser.parse(new Parsable().setQuery(queryString).setLanguage(actualLanguage)).getRoot();
    assertFalse(root instanceof NullItem);
    Query query = new Query("?language=" + queryLanguage.languageCode());
    query.getModel().getQueryTree().setRoot(root);
    new Execution(new Chain<Searcher>(new CJKSearcher()), new Execution.Context(null, indexFacts, null, null, linguistics)).search(query);
    assertEquals(expected, query.getModel().getQueryTree().getRoot().toString());
}
Also used : NullItem(com.yahoo.prelude.query.NullItem) Item(com.yahoo.prelude.query.Item) Chain(com.yahoo.component.chain.Chain) Execution(com.yahoo.search.searchchain.Execution) Query(com.yahoo.search.Query) Parsable(com.yahoo.search.query.parser.Parsable) ParserEnvironment(com.yahoo.search.query.parser.ParserEnvironment) CJKSearcher(com.yahoo.prelude.querytransform.CJKSearcher) NullItem(com.yahoo.prelude.query.NullItem) Parser(com.yahoo.search.query.parser.Parser)

Example 7 with NullItem

use of com.yahoo.prelude.query.NullItem in project vespa by vespa-engine.

the class ParsingTester method parseQuery.

public Item parseQuery(String query, String filter, Language language, Query.Type type, Linguistics linguistics) {
    Parser parser = ParserFactory.newInstance(type, new ParserEnvironment().setIndexFacts(indexFacts).setLinguistics(linguistics).setSpecialTokens(tokenRegistry.getSpecialTokens("default")));
    Item root = parser.parse(new Parsable().setQuery(query).setFilter(filter).setLanguage(language)).getRoot();
    if (root instanceof NullItem) {
        return null;
    }
    return root;
}
Also used : NullItem(com.yahoo.prelude.query.NullItem) Item(com.yahoo.prelude.query.Item) Parsable(com.yahoo.search.query.parser.Parsable) ParserEnvironment(com.yahoo.search.query.parser.ParserEnvironment) NullItem(com.yahoo.prelude.query.NullItem) Parser(com.yahoo.search.query.parser.Parser)

Aggregations

NullItem (com.yahoo.prelude.query.NullItem)7 Item (com.yahoo.prelude.query.Item)6 Parsable (com.yahoo.search.query.parser.Parsable)4 Parser (com.yahoo.search.query.parser.Parser)4 AndItem (com.yahoo.prelude.query.AndItem)3 CompositeItem (com.yahoo.prelude.query.CompositeItem)3 PhraseItem (com.yahoo.prelude.query.PhraseItem)3 WordItem (com.yahoo.prelude.query.WordItem)3 Query (com.yahoo.search.Query)3 ParserEnvironment (com.yahoo.search.query.parser.ParserEnvironment)3 AndSegmentItem (com.yahoo.prelude.query.AndSegmentItem)2 DotProductItem (com.yahoo.prelude.query.DotProductItem)2 EquivItem (com.yahoo.prelude.query.EquivItem)2 ExactStringItem (com.yahoo.prelude.query.ExactStringItem)2 IntItem (com.yahoo.prelude.query.IntItem)2 NearItem (com.yahoo.prelude.query.NearItem)2 NotItem (com.yahoo.prelude.query.NotItem)2 ONearItem (com.yahoo.prelude.query.ONearItem)2 OrItem (com.yahoo.prelude.query.OrItem)2 PhraseSegmentItem (com.yahoo.prelude.query.PhraseSegmentItem)2