Example usage for org.apache.solr.request SolrQueryRequestBase getParams

List of usage examples for org.apache.solr.request SolrQueryRequestBase getParams

Introduction

In this page you can find the example usage for org.apache.solr.request SolrQueryRequestBase getParams.

Prototype

@Override
    public SolrParams getParams() 

Source Link

Usage

From source file:net.yacy.search.index.SingleDocumentMatcher.java

License:Open Source License

/**
 * @param query a Solr query string to parse
 * @param targetCore an open Solr index core that is the target of the query
 * @return a lucene Query instance parsed from the given Solr query string on the provided Solr core.
 * @throws SyntaxError when the query syntax is not valid
 * @throws SolrException when a query required element is missing, or when a problem occurred when accessing the target core
 *///from w w w . j av a 2 s.c o m
public static Query toLuceneQuery(final String query, final SolrCore targetCore)
        throws SyntaxError, SolrException {
    if (query == null || targetCore == null) {
        throw new IllegalArgumentException("All parameters must be non null");
    }

    final SolrQuery solrQuery = new SolrQuery(query);
    solrQuery.setParam(CommonParams.DF, CollectionSchema.text_t.getSolrFieldName());

    final SolrQueryRequestBase solrRequest = new SolrQueryRequestBase(targetCore, solrQuery) {
    };

    final LuceneQParserPlugin luceneParserPlugin = new LuceneQParserPlugin();
    final QParser solrParser = luceneParserPlugin.createParser(query, null, solrRequest.getParams(),
            solrRequest);
    return solrParser.parse();
}