Example usage for org.apache.lucene.queryparser.flexible.core.nodes QueryNode add

List of usage examples for org.apache.lucene.queryparser.flexible.core.nodes QueryNode add

Introduction

In this page you can find the example usage for org.apache.lucene.queryparser.flexible.core.nodes QueryNode add.

Prototype

public void add(List<QueryNode> children);

Source Link

Usage

From source file:com.sindicetech.siren.qparser.keyword.BasicSyntaxTest.java

License:Open Source License

@Test(expected = IllegalArgumentException.class)
public void testTwigQueryNodeWithMoreThan2Children() throws Exception {
    final StandardExtendedKeywordQueryParser parser = new StandardExtendedKeywordQueryParser();
    final QueryNodeProcessorPipeline pipeline = new QueryNodeProcessorPipeline();
    pipeline.add(new QueryNodeProcessorImpl() {
        @Override//ww w  . j  av a  2 s .co  m
        protected List<QueryNode> setChildrenOrder(final List<QueryNode> children) throws QueryNodeException {
            return children;
        }

        @Override
        protected QueryNode preProcessNode(final QueryNode node) throws QueryNodeException {
            if (node instanceof TwigQueryNode) {
                node.add(new FieldQueryNode("field", "text", 0, 4));
            }
            return node;
        }

        @Override
        protected QueryNode postProcessNode(final QueryNode node) throws QueryNodeException {
            return node;
        }
    });
    parser.setQueryNodeProcessor(pipeline);

    parser.parse("a : b", SirenTestCase.DEFAULT_TEST_FIELD);
}

From source file:org.sindice.siren.qparser.keyword.KeywordQueryParserTest.java

License:Apache License

@Test(expected = IllegalArgumentException.class)
public void testTwigQueryNodeWithMoreThan2Children() throws Exception {
    final KeywordQueryParser parser = new KeywordQueryParser();
    final QueryNodeProcessorPipeline pipeline = new QueryNodeProcessorPipeline();
    pipeline.add(new QueryNodeProcessorImpl() {
        @Override/*from   ww w .j  av  a2 s  .co  m*/
        protected List<QueryNode> setChildrenOrder(final List<QueryNode> children) throws QueryNodeException {
            return children;
        }

        @Override
        protected QueryNode preProcessNode(final QueryNode node) throws QueryNodeException {
            if (node instanceof TwigQueryNode) {
                node.add(new FieldQueryNode("field", "text", 0, 4));
            }
            return node;
        }

        @Override
        protected QueryNode postProcessNode(final QueryNode node) throws QueryNodeException {
            return node;
        }
    });
    parser.setQueryNodeProcessor(pipeline);

    parser.parse("a : b", SirenTestCase.DEFAULT_TEST_FIELD);
}