Example usage for org.apache.lucene.queryParser.surround.query SrndQuery makeLuceneQueryField

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

Introduction

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

Prototype

public Query makeLuceneQueryField(String fieldName, BasicQueryFactory qf) 

Source Link

Usage

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

License:Apache License

@Override
public Query parse() throws SyntaxError {
    SrndQuery sq;
    String qstr = getString();//from   w ww  .  j av  a 2s  .  c om
    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;
}