Example usage for org.apache.lucene.queryParser.surround.query BasicQueryFactory BasicQueryFactory

List of usage examples for org.apache.lucene.queryParser.surround.query BasicQueryFactory BasicQueryFactory

Introduction

In this page you can find the example usage for org.apache.lucene.queryParser.surround.query BasicQueryFactory BasicQueryFactory.

Prototype

public BasicQueryFactory(int maxBasicQueries) 

Source Link

Usage

From source file:org.apache.solr.search.SurroundQParserPlugin.java

License:Apache License

@Override
public Query parse() throws SyntaxError {
    SrndQuery sq;//from   w w  w.  j a va  2  s  .c  o m
    String qstr = getString();
    if (qstr == null)
        return null;
    String mbqparam = getParam(MBQParam);
    if (mbqparam == null) {
        this.maxBasicQueries = DEFMAXBASICQUERIES;
    } else {
        try {
            this.maxBasicQueries = Integer.parseInt(mbqparam);
        } catch (Exception e) {
            LOG.warn("Couldn't parse maxBasicQueries value " + mbqparam + ", using default of 1000");
            this.maxBasicQueries = DEFMAXBASICQUERIES;
        }
    }
    // ugh .. colliding ParseExceptions
    try {
        sq = org.apache.lucene.queryparser.surround.parser.QueryParser.parse(qstr);
    } catch (org.apache.lucene.queryparser.surround.parser.ParseException pe) {
        throw new SyntaxError(pe);
    }

    // so what do we do with the SrndQuery ??
    // processing based on example in LIA Ch 9

    BasicQueryFactory bqFactory = new BasicQueryFactory(this.maxBasicQueries);
    String defaultField = QueryParsing.getDefaultField(getReq().getSchema(), getParam(CommonParams.DF));
    Query lquery = sq.makeLuceneQueryField(defaultField, bqFactory);
    return lquery;
}