Search in sources :

Example 1 with RegExpItem

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

the class YqlParserTestCase method testRegexp.

@Test
public void testRegexp() {
    QueryTree x = parse("select * from sources * where foo matches \"a b\";");
    Item root = x.getRoot();
    assertSame(RegExpItem.class, root.getClass());
    assertEquals("a b", ((RegExpItem) root).stringValue());
}
Also used : WordAlternativesItem(com.yahoo.prelude.query.WordAlternativesItem) ExactStringItem(com.yahoo.prelude.query.ExactStringItem) WeakAndItem(com.yahoo.prelude.query.WeakAndItem) IndexedItem(com.yahoo.prelude.query.IndexedItem) PrefixItem(com.yahoo.prelude.query.PrefixItem) Item(com.yahoo.prelude.query.Item) SuffixItem(com.yahoo.prelude.query.SuffixItem) PhraseItem(com.yahoo.prelude.query.PhraseItem) RegExpItem(com.yahoo.prelude.query.RegExpItem) SubstringItem(com.yahoo.prelude.query.SubstringItem) AndItem(com.yahoo.prelude.query.AndItem) WordItem(com.yahoo.prelude.query.WordItem) QueryTree(com.yahoo.search.query.QueryTree) Test(org.junit.Test)

Example 2 with RegExpItem

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

the class YqlParser method buildRegExpSearch.

@NonNull
private Item buildRegExpSearch(OperatorNode<ExpressionOperator> ast) {
    assertHasOperator(ast, ExpressionOperator.MATCHES);
    String field = getIndex(ast.<OperatorNode<ExpressionOperator>>getArgument(0));
    OperatorNode<ExpressionOperator> ast1 = ast.<OperatorNode<ExpressionOperator>>getArgument(1);
    String wordData = getStringContents(ast1);
    RegExpItem regExp = new RegExpItem(field, true, wordData);
    return leafStyleSettings(ast1, regExp);
}
Also used : RegExpItem(com.yahoo.prelude.query.RegExpItem) NonNull(edu.umd.cs.findbugs.annotations.NonNull)

Aggregations

RegExpItem (com.yahoo.prelude.query.RegExpItem)2 AndItem (com.yahoo.prelude.query.AndItem)1 ExactStringItem (com.yahoo.prelude.query.ExactStringItem)1 IndexedItem (com.yahoo.prelude.query.IndexedItem)1 Item (com.yahoo.prelude.query.Item)1 PhraseItem (com.yahoo.prelude.query.PhraseItem)1 PrefixItem (com.yahoo.prelude.query.PrefixItem)1 SubstringItem (com.yahoo.prelude.query.SubstringItem)1 SuffixItem (com.yahoo.prelude.query.SuffixItem)1 WeakAndItem (com.yahoo.prelude.query.WeakAndItem)1 WordAlternativesItem (com.yahoo.prelude.query.WordAlternativesItem)1 WordItem (com.yahoo.prelude.query.WordItem)1 QueryTree (com.yahoo.search.query.QueryTree)1 NonNull (edu.umd.cs.findbugs.annotations.NonNull)1 Test (org.junit.Test)1