Created
May 13, 2011 21:26
-
-
Save nhooey/971351 to your computer and use it in GitHub Desktop.
cannot find symbol
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[loading lucene-solr/solr/build/solr/org/apache/solr/search/QueryParsing.class] | |
src/com/thing/PayloadQParser.java:43: cannot find symbol | |
symbol : method getQueryParserDefaultOperator(org.apache.solr.schema.IndexSchema,java.lang.String) | |
location: class org.apache.solr.search.QueryParsing | |
lparser.setDefaultOperator(QueryParsing.getQueryParserDefaultOperator( | |
^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.thing; | |
import org.apache.solr.search.QParser; | |
import org.apache.solr.search.SolrQueryParser; | |
import org.apache.solr.search.QueryParsing; | |
import org.apache.solr.request.SolrQueryRequest; | |
import org.apache.solr.common.params.SolrParams; | |
import org.apache.solr.common.params.CommonParams; | |
import org.apache.lucene.queryParser.ParseException; | |
import org.apache.lucene.search.Query; | |
import org.apache.lucene.search.payloads.PayloadTermQuery; | |
import org.apache.lucene.search.payloads.AveragePayloadFunction; | |
import org.apache.lucene.search.BooleanQuery; | |
import org.apache.lucene.search.BooleanClause; | |
import org.apache.lucene.search.BooleanClause.Occur; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
import java.util.List; | |
public class PayloadQParser extends QParser { | |
String sortStr; | |
SolrQueryParser lparser; | |
Logger log; | |
public PayloadQParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) { | |
super(qstr, localParams, params, req); | |
this.log = LoggerFactory.getLogger(PayloadQParser.class); | |
} | |
@Override | |
public Query parse() throws ParseException { | |
String qstr = getString(); | |
if (qstr == null) return null; | |
String defaultField = getParam(CommonParams.DF); | |
if (defaultField == null) { | |
defaultField = getReq().getSchema().getDefaultSearchFieldName(); | |
} | |
lparser = new SolrQueryParser(this, defaultField); | |
lparser.setDefaultOperator(QueryParsing.getQueryParserDefaultOperator( | |
getReq().getSchema(), | |
getParam(QueryParsing.OP) | |
)); | |
Query q = lparser.parse(qstr); | |
BooleanQuery bq = null; | |
bq = (BooleanQuery) q; | |
log.warn(qstr); | |
List<BooleanClause> clauses = bq.clauses(); | |
for (BooleanClause c : clauses) { | |
log.warn(c.toString()); | |
} | |
return bq; | |
} | |
@Override | |
public String[] getDefaultHighlightFields() { | |
return lparser == null | |
? new String[]{} | |
: new String[]{lparser.getField()}; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class QueryParsing { | |
public static final String OP = "q.op"; // the SolrParam used to override the QueryParser "default operator" | |
public static final String V = "v"; // value of this parameter | |
public static final String F = "f"; // field that a query or command pertains to | |
public static final String TYPE = "type";// type of this query or command | |
public static final String DEFTYPE = "defType"; // default type for any direct subqueries | |
public static final String LOCALPARAM_START = "{!"; | |
public static final char LOCALPARAM_END = '}'; | |
public static final String DOCID = "_docid_"; | |
public static final String SCORE = "score"; | |
// true if the value was specified by the "v" param (i.e. v=myval, or v=$param) | |
public static final String VAL_EXPLICIT = "__VAL_EXPLICIT__"; | |
/** | |
* Returns the "prefered" default operator for use by Query Parsers, | |
* based on the settings in the IndexSchema which may be overridden using | |
* an optional String override value. | |
* | |
* @see IndexSchema#getQueryParserDefaultOperator() | |
* @see #OP | |
*/ | |
public static Operator getQueryParserDefaultOperator(final IndexSchema sch, | |
final String override) { | |
String val = override; | |
if (null == val) val = sch.getQueryParserDefaultOperator(); | |
return "AND".equals(val) ? Operator.AND : Operator.OR; | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment