You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by yo...@apache.org on 2012/11/23 20:46:01 UTC
svn commit: r1413042 [3/4] - in /lucene/dev/trunk/solr: ./ core/
core/src/java/org/apache/solr/handler/
core/src/java/org/apache/solr/handler/component/
core/src/java/org/apache/solr/parser/
core/src/java/org/apache/solr/request/ core/src/java/org/apac...
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/request/SimpleFacets.java Fri Nov 23 19:45:50 2012
@@ -18,7 +18,6 @@
package org.apache.solr.request;
import org.apache.lucene.index.*;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.*;
import org.apache.lucene.search.grouping.AbstractAllGroupHeadsCollector;
import org.apache.lucene.search.grouping.term.TermGroupFacetCollector;
@@ -95,7 +94,7 @@ public class SimpleFacets {
}
- protected void parseParams(String type, String param) throws ParseException, IOException {
+ protected void parseParams(String type, String param) throws SyntaxError, IOException {
localParams = QueryParsing.getLocalParams(param, req.getParams());
docs = docsOrig;
facetValue = param;
@@ -209,7 +208,7 @@ public class SimpleFacets {
} catch (IOException e) {
throw new SolrException(ErrorCode.SERVER_ERROR, e);
- } catch (ParseException e) {
+ } catch (SyntaxError e) {
throw new SolrException(ErrorCode.BAD_REQUEST, e);
}
return facetResponse;
@@ -221,7 +220,7 @@ public class SimpleFacets {
*
* @see FacetParams#FACET_QUERY
*/
- public NamedList<Integer> getFacetQueryCounts() throws IOException,ParseException {
+ public NamedList<Integer> getFacetQueryCounts() throws IOException,SyntaxError {
NamedList<Integer> res = new SimpleOrderedMap<Integer>();
@@ -409,7 +408,7 @@ public class SimpleFacets {
* @see #getFacetTermEnumCounts
*/
public NamedList<Object> getFacetFieldCounts()
- throws IOException, ParseException {
+ throws IOException, SyntaxError {
NamedList<Object> res = new SimpleOrderedMap<Object>();
String[] facetFs = params.getParams(FacetParams.FACET_FIELD);
@@ -826,7 +825,7 @@ public class SimpleFacets {
*/
@Deprecated
public NamedList<Object> getFacetDateCounts()
- throws IOException, ParseException {
+ throws IOException, SyntaxError {
final NamedList<Object> resOuter = new SimpleOrderedMap<Object>();
final String[] fields = params.getParams(FacetParams.FACET_DATE);
@@ -845,7 +844,7 @@ public class SimpleFacets {
*/
@Deprecated
public void getFacetDateCounts(String dateFacet, NamedList<Object> resOuter)
- throws IOException, ParseException {
+ throws IOException, SyntaxError {
final IndexSchema schema = searcher.getSchema();
@@ -1008,7 +1007,7 @@ public class SimpleFacets {
* @see FacetParams#FACET_RANGE
*/
- public NamedList<Object> getFacetRangeCounts() throws IOException, ParseException {
+ public NamedList<Object> getFacetRangeCounts() throws IOException, SyntaxError {
final NamedList<Object> resOuter = new SimpleOrderedMap<Object>();
final String[] fields = params.getParams(FacetParams.FACET_RANGE);
@@ -1022,7 +1021,7 @@ public class SimpleFacets {
}
void getFacetRangeCounts(String facetRange, NamedList<Object> resOuter)
- throws IOException, ParseException {
+ throws IOException, SyntaxError {
final IndexSchema schema = searcher.getSchema();
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/BoostQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/BoostQParserPlugin.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/BoostQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/BoostQParserPlugin.java Fri Nov 23 19:45:50 2012
@@ -20,7 +20,6 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.QueryValueSource;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
@@ -52,7 +51,7 @@ public class BoostQParserPlugin extends
String b;
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
b = localParams.get(BOOSTFUNC);
baseParser = subQuery(localParams.get(QueryParsing.V), null);
Query q = baseParser.getQuery();
@@ -74,7 +73,7 @@ public class BoostQParserPlugin extends
}
@Override
- public Query getHighlightQuery() throws ParseException {
+ public Query getHighlightQuery() throws SyntaxError {
return baseParser.getHighlightQuery();
}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/DisMaxQParser.java Fri Nov 23 19:45:50 2012
@@ -16,12 +16,11 @@
*/
package org.apache.solr.search;
-import org.apache.lucene.queryparser.classic.ParseException;
-import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.Query;
import org.apache.solr.common.params.CommonParams;
+import org.apache.solr.parser.QueryParser;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.common.params.DisMaxParams;
import org.apache.solr.common.params.SolrParams;
@@ -58,8 +57,8 @@ public class DisMaxQParser extends QPars
*/
public static String parseMinShouldMatch(final IndexSchema schema,
final SolrParams params) {
- QueryParser.Operator op = QueryParsing.getQueryParserDefaultOperator
- (schema, params.get(QueryParsing.OP));
+ org.apache.solr.parser.QueryParser.Operator op = QueryParsing.getQueryParserDefaultOperator
+ (schema, params.get(QueryParsing.OP));
return params.get(DisMaxParams.MM,
op.equals(QueryParser.Operator.AND) ? "100%" : "0%");
}
@@ -69,12 +68,12 @@ public class DisMaxQParser extends QPars
* or {@link org.apache.solr.schema.IndexSchema#getDefaultSearchFieldName()}.
*/
public static Map<String, Float> parseQueryFields(final IndexSchema indexSchema, final SolrParams solrParams)
- throws ParseException {
+ throws SyntaxError {
Map<String, Float> queryFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.QF));
if (queryFields.isEmpty()) {
String df = QueryParsing.getDefaultField(indexSchema, solrParams.get(CommonParams.DF));
if (df == null) {
- throw new ParseException("Neither "+DisMaxParams.QF+", "+CommonParams.DF +", nor the default search field are present.");
+ throw new SyntaxError("Neither "+DisMaxParams.QF+", "+CommonParams.DF +", nor the default search field are present.");
}
queryFields.put(df, 1.0f);
}
@@ -96,7 +95,7 @@ public class DisMaxQParser extends QPars
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
SolrParams solrParams = SolrParams.wrapDefaults(localParams, params);
queryFields = parseQueryFields(req.getSchema(), solrParams);
@@ -115,7 +114,7 @@ public class DisMaxQParser extends QPars
return query;
}
- protected void addBoostFunctions(BooleanQuery query, SolrParams solrParams) throws ParseException {
+ protected void addBoostFunctions(BooleanQuery query, SolrParams solrParams) throws SyntaxError {
String[] boostFuncs = solrParams.getParams(DisMaxParams.BF);
if (null != boostFuncs && 0 != boostFuncs.length) {
for (String boostFunc : boostFuncs) {
@@ -133,7 +132,7 @@ public class DisMaxQParser extends QPars
}
}
- protected void addBoostQuery(BooleanQuery query, SolrParams solrParams) throws ParseException {
+ protected void addBoostQuery(BooleanQuery query, SolrParams solrParams) throws SyntaxError {
boostParams = solrParams.getParams(DisMaxParams.BQ);
//List<Query> boostQueries = SolrPluginUtils.parseQueryStrings(req, boostParams);
boostQueries = null;
@@ -168,7 +167,7 @@ public class DisMaxQParser extends QPars
}
/** Adds the main query to the query argument. If its blank then false is returned. */
- protected boolean addMainQuery(BooleanQuery query, SolrParams solrParams) throws ParseException {
+ protected boolean addMainQuery(BooleanQuery query, SolrParams solrParams) throws SyntaxError {
Map<String, Float> phraseFields = SolrPluginUtils.parseFieldBoosts(solrParams.getParams(DisMaxParams.PF));
float tiebreaker = solrParams.getFloat(DisMaxParams.TIE, 0.0f);
@@ -206,7 +205,7 @@ public class DisMaxQParser extends QPars
return true;
}
- protected Query getAlternateUserQuery(SolrParams solrParams) throws ParseException {
+ protected Query getAlternateUserQuery(SolrParams solrParams) throws SyntaxError {
String altQ = solrParams.get(DisMaxParams.ALTQ);
if (altQ != null) {
QParser altQParser = subQuery(altQ, null);
@@ -216,7 +215,7 @@ public class DisMaxQParser extends QPars
}
}
- protected Query getPhraseQuery(String userQuery, SolrPluginUtils.DisjunctionMaxQueryParser pp) throws ParseException {
+ protected Query getPhraseQuery(String userQuery, SolrPluginUtils.DisjunctionMaxQueryParser pp) throws SyntaxError {
/* * * Add on Phrases for the Query * * */
/* build up phrase boosting queries */
@@ -231,7 +230,9 @@ public class DisMaxQParser extends QPars
}
protected Query getUserQuery(String userQuery, SolrPluginUtils.DisjunctionMaxQueryParser up, SolrParams solrParams)
- throws ParseException {
+ throws SyntaxError {
+
+
String minShouldMatch = parseMinShouldMatch(req.getSchema(), solrParams);
Query dis = up.parse(userQuery);
Query query = dis;
@@ -261,7 +262,7 @@ public class DisMaxQParser extends QPars
}
@Override
- public Query getHighlightQuery() throws ParseException {
+ public Query getHighlightQuery() throws SyntaxError {
return parsedUserQuery == null ? altUserQuery : parsedUserQuery;
}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ExtendedDismaxQParserPlugin.java Fri Nov 23 19:45:50 2012
@@ -34,11 +34,11 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.ProductFloatFunction;
import org.apache.lucene.queries.function.valuesource.QueryValueSource;
-import org.apache.lucene.queryparser.classic.ParseException;
-import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*;
import org.apache.solr.analysis.TokenizerChain;
-import org.apache.solr.search.SolrQueryParser.MagicFieldName;
+import org.apache.solr.parser.ParseException;
+import org.apache.solr.parser.QueryParser;
+import org.apache.solr.parser.SolrQueryParserBase.MagicFieldName;
import org.apache.solr.common.params.DisMaxParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
@@ -118,7 +118,7 @@ class ExtendedDismaxQParser extends QPar
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
SolrParams localParams = getLocalParams();
SolrParams params = getParams();
@@ -173,7 +173,7 @@ class ExtendedDismaxQParser extends QPar
query.add( altUserQuery , BooleanClause.Occur.MUST );
} else {
return null;
- // throw new ParseException("missing query string" );
+ // throw new SyntaxError("missing query string" );
}
}
else {
@@ -451,7 +451,7 @@ class ExtendedDismaxQParser extends QPar
int shingleSize,
final float tiebreaker,
final int slop)
- throws ParseException {
+ throws SyntaxError {
if (null == fields || fields.isEmpty() ||
null == clauses || clauses.size() < shingleSize )
@@ -519,7 +519,7 @@ class ExtendedDismaxQParser extends QPar
}
@Override
- public Query getHighlightQuery() throws ParseException {
+ public Query getHighlightQuery() throws SyntaxError {
return parsedUserQuery == null ? altUserQuery : parsedUserQuery;
}
@@ -900,7 +900,7 @@ class ExtendedDismaxQParser extends QPar
protected Map<String,Alias> aliases = new HashMap<String,Alias>(3);
public ExtendedSolrQueryParser(QParser parser, String defaultField) {
- super(parser, defaultField, null);
+ super(parser, defaultField);
// don't trust that our parent class won't ever change it's default
setDefaultOperator(QueryParser.Operator.OR);
}
@@ -911,7 +911,7 @@ class ExtendedDismaxQParser extends QPar
}
@Override
- protected Query getBooleanQuery(List clauses, boolean disableCoord) throws ParseException {
+ protected Query getBooleanQuery(List clauses, boolean disableCoord) throws SyntaxError {
Query q = super.getBooleanQuery(clauses, disableCoord);
if (q != null) {
q = QueryUtils.makeQueryable(q);
@@ -971,7 +971,7 @@ class ExtendedDismaxQParser extends QPar
int slop;
@Override
- protected Query getFieldQuery(String field, String val, boolean quoted) throws ParseException {
+ protected Query getFieldQuery(String field, String val, boolean quoted) throws SyntaxError {
//System.out.println("getFieldQuery: val="+val);
this.type = QType.FIELD;
@@ -982,7 +982,7 @@ class ExtendedDismaxQParser extends QPar
}
@Override
- protected Query getFieldQuery(String field, String val, int slop) throws ParseException {
+ protected Query getFieldQuery(String field, String val, int slop) throws SyntaxError {
//System.out.println("getFieldQuery: val="+val+" slop="+slop);
this.type = QType.PHRASE;
@@ -993,7 +993,7 @@ class ExtendedDismaxQParser extends QPar
}
@Override
- protected Query getPrefixQuery(String field, String val) throws ParseException {
+ protected Query getPrefixQuery(String field, String val) throws SyntaxError {
//System.out.println("getPrefixQuery: val="+val);
if (val.equals("") && field.equals("*")) {
return new MatchAllDocsQuery();
@@ -1005,7 +1005,7 @@ class ExtendedDismaxQParser extends QPar
}
@Override
- protected Query newFieldQuery(Analyzer analyzer, String field, String queryText, boolean quoted) throws ParseException {
+ protected Query newFieldQuery(Analyzer analyzer, String field, String queryText, boolean quoted) throws SyntaxError {
Analyzer actualAnalyzer;
if (removeStopFilter) {
if (nonStopFilterAnalyzerPerField == null) {
@@ -1022,7 +1022,7 @@ class ExtendedDismaxQParser extends QPar
}
@Override
- protected Query getRangeQuery(String field, String a, String b, boolean startInclusive, boolean endInclusive) throws ParseException {
+ protected Query getRangeQuery(String field, String a, String b, boolean startInclusive, boolean endInclusive) throws SyntaxError {
//System.out.println("getRangeQuery:");
this.type = QType.RANGE;
@@ -1035,7 +1035,7 @@ class ExtendedDismaxQParser extends QPar
}
@Override
- protected Query getWildcardQuery(String field, String val) throws ParseException {
+ protected Query getWildcardQuery(String field, String val) throws SyntaxError {
//System.out.println("getWildcardQuery: val="+val);
if (val.equals("*")) {
@@ -1052,7 +1052,7 @@ class ExtendedDismaxQParser extends QPar
}
@Override
- protected Query getFuzzyQuery(String field, String val, float minSimilarity) throws ParseException {
+ protected Query getFuzzyQuery(String field, String val, float minSimilarity) throws SyntaxError {
//System.out.println("getFuzzyQuery: val="+val);
this.type = QType.FUZZY;
@@ -1069,7 +1069,7 @@ class ExtendedDismaxQParser extends QPar
* DisjunctionMaxQuery. (so yes: aliases which point at other
* aliases should work)
*/
- protected Query getAliasedQuery() throws ParseException {
+ protected Query getAliasedQuery() throws SyntaxError {
Alias a = aliases.get(field);
this.validateCyclicAliasing(field);
if (a != null) {
@@ -1112,11 +1112,11 @@ class ExtendedDismaxQParser extends QPar
/**
* Validate there is no cyclic referencing in the aliasing
*/
- private void validateCyclicAliasing(String field) throws ParseException {
+ private void validateCyclicAliasing(String field) throws SyntaxError {
Set<String> set = new HashSet<String>();
set.add(field);
if(validateField(field, set)) {
- throw new ParseException("Field aliases lead to a cycle");
+ throw new SyntaxError("Field aliases lead to a cycle");
}
}
@@ -1138,7 +1138,7 @@ class ExtendedDismaxQParser extends QPar
return hascycle;
}
- protected List<Query> getQueries(Alias a) throws ParseException {
+ protected List<Query> getQueries(Alias a) throws SyntaxError {
if (a == null) return null;
if (a.fields.size()==0) return null;
List<Query> lst= new ArrayList<Query>(4);
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionQParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionQParser.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionQParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionQParser.java Fri Nov 23 19:45:50 2012
@@ -19,12 +19,10 @@ package org.apache.solr.search;
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.*;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.SchemaField;
-import org.apache.solr.search.function.*;
import java.util.ArrayList;
import java.util.HashMap;
@@ -60,7 +58,7 @@ public class FunctionQParser extends QPa
}
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
sp = new QueryParsing.StrParser(getString());
ValueSource vs = null;
@@ -92,7 +90,7 @@ public class FunctionQParser extends QPa
}
if (parseToEnd && sp.pos < sp.end) {
- throw new ParseException("Unexpected text after function: " + sp.val.substring(sp.pos, sp.end));
+ throw new SyntaxError("Unexpected text after function: " + sp.val.substring(sp.pos, sp.end));
}
if (lst != null) {
@@ -107,7 +105,7 @@ public class FunctionQParser extends QPa
*
* @return whether more args exist
*/
- public boolean hasMoreArguments() throws ParseException {
+ public boolean hasMoreArguments() throws SyntaxError {
int ch = sp.peek();
/* determine whether the function is ending with a paren or end of str */
return (! (ch == 0 || ch == ')') );
@@ -116,9 +114,9 @@ public class FunctionQParser extends QPa
/*
* TODO: Doc
*/
- public String parseId() throws ParseException {
+ public String parseId() throws SyntaxError {
String value = parseArg();
- if (argWasQuoted) throw new ParseException("Expected identifier instead of quoted string:" + value);
+ if (argWasQuoted) throw new SyntaxError("Expected identifier instead of quoted string:" + value);
return value;
}
@@ -127,9 +125,9 @@ public class FunctionQParser extends QPa
*
* @return Float
*/
- public Float parseFloat() throws ParseException {
+ public Float parseFloat() throws SyntaxError {
String str = parseArg();
- if (argWasQuoted()) throw new ParseException("Expected float instead of quoted string:" + str);
+ if (argWasQuoted()) throw new SyntaxError("Expected float instead of quoted string:" + str);
float value = Float.parseFloat(str);
return value;
}
@@ -138,9 +136,9 @@ public class FunctionQParser extends QPa
* Parse a Double
* @return double
*/
- public double parseDouble() throws ParseException {
+ public double parseDouble() throws SyntaxError {
String str = parseArg();
- if (argWasQuoted()) throw new ParseException("Expected double instead of quoted string:" + str);
+ if (argWasQuoted()) throw new SyntaxError("Expected double instead of quoted string:" + str);
double value = Double.parseDouble(str);
return value;
}
@@ -149,9 +147,9 @@ public class FunctionQParser extends QPa
* Parse an integer
* @return An int
*/
- public int parseInt() throws ParseException {
+ public int parseInt() throws SyntaxError {
String str = parseArg();
- if (argWasQuoted()) throw new ParseException("Expected double instead of quoted string:" + str);
+ if (argWasQuoted()) throw new SyntaxError("Expected double instead of quoted string:" + str);
int value = Integer.parseInt(str);
return value;
}
@@ -162,7 +160,7 @@ public class FunctionQParser extends QPa
return argWasQuoted;
}
- public String parseArg() throws ParseException {
+ public String parseArg() throws SyntaxError {
argWasQuoted = false;
sp.eatws();
@@ -186,7 +184,7 @@ public class FunctionQParser extends QPa
int valStart = sp.pos;
for (;;) {
if (sp.pos >= sp.end) {
- throw new ParseException("Missing end to unquoted value starting at " + valStart + " str='" + sp.val +"'");
+ throw new SyntaxError("Missing end to unquoted value starting at " + valStart + " str='" + sp.val +"'");
}
char c = sp.val.charAt(sp.pos);
if (c==')' || c==',' || Character.isWhitespace(c)) {
@@ -209,7 +207,7 @@ public class FunctionQParser extends QPa
*
* @return List<ValueSource>
*/
- public List<ValueSource> parseValueSourceList() throws ParseException {
+ public List<ValueSource> parseValueSourceList() throws SyntaxError {
List<ValueSource> sources = new ArrayList<ValueSource>(3);
while (hasMoreArguments()) {
sources.add(parseValueSource(true));
@@ -220,7 +218,7 @@ public class FunctionQParser extends QPa
/**
* Parse an individual ValueSource.
*/
- public ValueSource parseValueSource() throws ParseException {
+ public ValueSource parseValueSource() throws SyntaxError {
/* consume the delimiter afterward for an external call to parseValueSource */
return parseValueSource(true);
}
@@ -228,7 +226,7 @@ public class FunctionQParser extends QPa
/*
* TODO: Doc
*/
- public Query parseNestedQuery() throws ParseException {
+ public Query parseNestedQuery() throws SyntaxError {
Query nestedQuery;
if (sp.opt("$")) {
@@ -257,10 +255,10 @@ public class FunctionQParser extends QPa
sub = subQuery(qs, null);
// int subEnd = sub.findEnd(')');
// TODO.. implement functions to find the end of a nested query
- throw new ParseException("Nested local params must have value in v parameter. got '" + qs + "'");
+ throw new SyntaxError("Nested local params must have value in v parameter. got '" + qs + "'");
}
} else {
- throw new ParseException("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
+ throw new SyntaxError("Nested function query must use $param or {!v=value} forms. got '" + qs + "'");
}
sp.pos += end-start; // advance past nested query
@@ -276,7 +274,7 @@ public class FunctionQParser extends QPa
*
* @param doConsumeDelimiter whether to consume a delimiter following the ValueSource
*/
- protected ValueSource parseValueSource(boolean doConsumeDelimiter) throws ParseException {
+ protected ValueSource parseValueSource(boolean doConsumeDelimiter) throws SyntaxError {
ValueSource valueSource;
int ch = sp.peek();
@@ -297,7 +295,7 @@ public class FunctionQParser extends QPa
String param = sp.getId();
String val = getParam(param);
if (val == null) {
- throw new ParseException("Missing param " + param + " while parsing function '" + sp.val + "'");
+ throw new SyntaxError("Missing param " + param + " while parsing function '" + sp.val + "'");
}
QParser subParser = subQuery(val, "func");
@@ -349,7 +347,7 @@ public class FunctionQParser extends QPa
// a function... look it up.
ValueSourceParser argParser = req.getCore().getValueSourceParser(id);
if (argParser==null) {
- throw new ParseException("Unknown function " + id + " in FunctionQuery(" + sp + ")");
+ throw new SyntaxError("Unknown function " + id + " in FunctionQuery(" + sp + ")");
}
valueSource = argParser.parse(this);
sp.expect(")");
@@ -379,7 +377,7 @@ public class FunctionQParser extends QPa
*
* @return whether a delimiter was consumed
*/
- protected boolean consumeArgumentDelimiter() throws ParseException {
+ protected boolean consumeArgumentDelimiter() throws SyntaxError {
/* if a list of args is ending, don't expect the comma */
if (hasMoreArguments()) {
sp.expect(",");
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionRangeQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionRangeQParserPlugin.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionRangeQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/FunctionRangeQParserPlugin.java Fri Nov 23 19:45:50 2012
@@ -16,23 +16,15 @@
*/
package org.apache.solr.search;
-import org.apache.lucene.index.IndexReader;
-import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queries.function.ValueSourceScorer;
import org.apache.lucene.queries.function.valuesource.QueryValueSource;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.*;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
-import org.apache.solr.core.SolrConfig;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.search.function.*;
-import java.io.IOException;
-import java.util.Map;
-
/**
* Create a range query over a function.
* <br>Other parameters:
@@ -56,7 +48,7 @@ public class FunctionRangeQParserPlugin
String funcStr;
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
funcStr = localParams.get(QueryParsing.V, null);
Query funcQ = subQuery(funcStr, FunctionQParserPlugin.NAME).getQuery();
if (funcQ instanceof FunctionQuery) {
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/Grouping.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/Grouping.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/Grouping.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/Grouping.java Fri Nov 23 19:45:50 2012
@@ -18,12 +18,10 @@
package org.apache.solr.search;
import org.apache.commons.lang.ArrayUtils;
-import org.apache.lucene.index.IndexableField;
import org.apache.lucene.index.StorableField;
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.QueryValueSource;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.*;
import org.apache.lucene.search.grouping.*;
import org.apache.lucene.search.grouping.function.FunctionAllGroupHeadsCollector;
@@ -128,7 +126,7 @@ public class Grouping {
*
* @param field The fieldname to group by.
*/
- public void addFieldCommand(String field, SolrQueryRequest request) throws ParseException {
+ public void addFieldCommand(String field, SolrQueryRequest request) throws SyntaxError {
SchemaField schemaField = searcher.getSchema().getField(field); // Throws an exception when field doesn't exist. Bad request.
FieldType fieldType = schemaField.getType();
ValueSource valueSource = fieldType.getValueSource(schemaField, null);
@@ -160,7 +158,7 @@ public class Grouping {
commands.add(gc);
}
- public void addFunctionCommand(String groupByStr, SolrQueryRequest request) throws ParseException {
+ public void addFunctionCommand(String groupByStr, SolrQueryRequest request) throws SyntaxError {
QParser parser = QParser.getParser(groupByStr, "func", request);
Query q = parser.getQuery();
final Grouping.Command gc;
@@ -203,7 +201,7 @@ public class Grouping {
commands.add(gc);
}
- public void addQueryCommand(String groupByStr, SolrQueryRequest request) throws ParseException {
+ public void addQueryCommand(String groupByStr, SolrQueryRequest request) throws SyntaxError {
QParser parser = QParser.getParser(groupByStr, null, request);
Query gq = parser.getQuery();
Grouping.CommandQuery gc = new CommandQuery();
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/JoinQParserPlugin.java Fri Nov 23 19:45:50 2012
@@ -17,7 +17,6 @@
package org.apache.solr.search;
import org.apache.lucene.index.*;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.*;
import org.apache.lucene.search.similarities.Similarity;
import org.apache.lucene.util.Bits;
@@ -53,7 +52,7 @@ public class JoinQParserPlugin extends Q
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req) {
return new QParser(qstr, localParams, params, req) {
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
String fromField = getParam("from");
String fromIndex = getParam("fromIndex");
String toField = getParam("to");
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/LuceneQParserPlugin.java Fri Nov 23 19:45:50 2012
@@ -16,7 +16,6 @@
*/
package org.apache.solr.search;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Sort;
import org.apache.solr.common.params.CommonParams;
@@ -55,7 +54,7 @@ class LuceneQParser extends QParser {
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
String qstr = getString();
if (qstr == null || qstr.length()==0) return null;
@@ -75,7 +74,7 @@ class LuceneQParser extends QParser {
@Override
public String[] getDefaultHighlightFields() {
- return lparser == null ? new String[]{} : new String[]{lparser.getField()};
+ return lparser == null ? new String[]{} : new String[]{lparser.getDefaultField()};
}
}
@@ -89,7 +88,7 @@ class OldLuceneQParser extends LuceneQPa
}
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
// handle legacy "query;sort" syntax
if (getLocalParams() == null) {
String qstr = getString();
@@ -107,7 +106,7 @@ class OldLuceneQParser extends LuceneQPa
qstr = commands.get(0);
}
else if (commands.size() > 2) {
- throw new ParseException("If you want to use multiple ';' in the query, use the 'sort' param.");
+ throw new SyntaxError("If you want to use multiple ';' in the query, use the 'sort' param.");
}
}
setString(qstr);
@@ -117,7 +116,7 @@ class OldLuceneQParser extends LuceneQPa
}
@Override
- public SortSpec getSort(boolean useGlobal) throws ParseException {
+ public SortSpec getSort(boolean useGlobal) throws SyntaxError {
SortSpec sort = super.getSort(useGlobal);
if (sortStr != null && sortStr.length()>0 && sort.getSort()==null) {
Sort oldSort = QueryParsing.parseSort(sortStr, getReq());
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/NestedQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/NestedQParserPlugin.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/NestedQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/NestedQParserPlugin.java Fri Nov 23 19:45:50 2012
@@ -17,7 +17,6 @@
package org.apache.solr.search;
import org.apache.lucene.queries.function.ValueSource;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
@@ -46,7 +45,7 @@ public class NestedQParserPlugin extends
String b;
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
baseParser = subQuery(localParams.get(QueryParsing.V), null);
return baseParser.getQuery();
}
@@ -57,7 +56,7 @@ public class NestedQParserPlugin extends
}
@Override
- public Query getHighlightQuery() throws ParseException {
+ public Query getHighlightQuery() throws SyntaxError {
return baseParser.getHighlightQuery();
}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QParser.java Fri Nov 23 19:45:50 2012
@@ -16,7 +16,6 @@
*/
package org.apache.solr.search;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.ScoreDoc; //Issue 1726
import org.apache.lucene.search.Sort;
@@ -100,7 +99,7 @@ public abstract class QParser {
* there was no input (e.g. no query string) to parse.
* @see #getQuery()
**/
- public abstract Query parse() throws ParseException;
+ public abstract Query parse() throws SyntaxError;
public SolrParams getLocalParams() {
return localParams;
@@ -138,7 +137,7 @@ public abstract class QParser {
* Returns the resulting query from this QParser, calling parse() only the
* first time and caching the Query result.
*/
- public Query getQuery() throws ParseException {
+ public Query getQuery() throws SyntaxError {
if (query==null) {
query=parse();
@@ -174,9 +173,9 @@ public abstract class QParser {
}
}
- private void checkRecurse() throws ParseException {
+ private void checkRecurse() throws SyntaxError {
if (recurseCount++ >= 100) {
- throw new ParseException("Infinite Recursion detected parsing query '" + qstr + "'");
+ throw new SyntaxError("Infinite Recursion detected parsing query '" + qstr + "'");
}
}
@@ -197,7 +196,7 @@ public abstract class QParser {
}
/** Create a new QParser for parsing an embedded sub-query */
- public QParser subQuery(String q, String defaultType) throws ParseException {
+ public QParser subQuery(String q, String defaultType) throws SyntaxError {
checkRecurse();
if (defaultType == null && localParams != null) {
// if not passed, try and get the defaultType from local params
@@ -213,7 +212,7 @@ public abstract class QParser {
* use common params to look up pageScore and pageDoc in global params
* @return the ScoreDoc
*/
- public ScoreDoc getPaging() throws ParseException
+ public ScoreDoc getPaging() throws SyntaxError
{
return null;
@@ -244,7 +243,7 @@ public abstract class QParser {
* @param useGlobalParams look up sort, start, rows in global params if not in local params
* @return the sort specification
*/
- public SortSpec getSort(boolean useGlobalParams) throws ParseException {
+ public SortSpec getSort(boolean useGlobalParams) throws SyntaxError {
getQuery(); // ensure query is parsed first
String sortStr = null;
@@ -288,7 +287,7 @@ public abstract class QParser {
return new String[]{};
}
- public Query getHighlightQuery() throws ParseException {
+ public Query getHighlightQuery() throws SyntaxError {
Query query = getQuery();
return query instanceof WrappedQuery ? ((WrappedQuery)query).getWrappedQuery() : query;
}
@@ -306,7 +305,7 @@ public abstract class QParser {
* if qstr=<code>{!prefix f=myfield}foo</code>
* then the prefix query parser will be used.
*/
- public static QParser getParser(String qstr, String defaultParser, SolrQueryRequest req) throws ParseException {
+ public static QParser getParser(String qstr, String defaultParser, SolrQueryRequest req) throws SyntaxError {
// SolrParams localParams = QueryParsing.getLocalParams(qstr, req.getParams());
String stringIncludingLocalParams = qstr;
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QueryParsing.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QueryParsing.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QueryParsing.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/QueryParsing.java Fri Nov 23 19:45:50 2012
@@ -20,8 +20,6 @@ package org.apache.solr.search;
import org.apache.lucene.index.Term;
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.valuesource.QueryValueSource;
-import org.apache.lucene.queryparser.classic.ParseException;
-import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.BooleanClause;
import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.ConstantScoreQuery;
@@ -39,6 +37,7 @@ import org.apache.lucene.util.CharsRef;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.MapSolrParams;
import org.apache.solr.common.params.SolrParams;
+import org.apache.solr.parser.QueryParser;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.IndexSchema;
@@ -95,12 +94,12 @@ public class QueryParsing {
}
// note to self: something needs to detect infinite recursion when parsing queries
- public static int parseLocalParams(String txt, int start, Map<String, String> target, SolrParams params) throws ParseException {
+ public static int parseLocalParams(String txt, int start, Map<String, String> target, SolrParams params) throws SyntaxError {
return parseLocalParams(txt, start, target, params, LOCALPARAM_START, LOCALPARAM_END);
}
- public static int parseLocalParams(String txt, int start, Map<String, String> target, SolrParams params, String startString, char endChar) throws ParseException {
+ public static int parseLocalParams(String txt, int start, Map<String, String> target, SolrParams params, String startString, char endChar) throws SyntaxError {
int off = start;
if (!txt.startsWith(startString, off)) return start;
StrParser p = new StrParser(txt, start, txt.length());
@@ -109,7 +108,7 @@ public class QueryParsing {
for (; ;) {
/*
if (p.pos>=txt.length()) {
- throw new ParseException("Missing '}' parsing local params '" + txt + '"');
+ throw new SyntaxError("Missing '}' parsing local params '" + txt + '"');
}
*/
char ch = p.peek();
@@ -119,7 +118,7 @@ public class QueryParsing {
String id = p.getId();
if (id.length() == 0) {
- throw new ParseException("Expected ending character '" + endChar + "' parsing local params '" + txt + '"');
+ throw new SyntaxError("Expected ending character '" + endChar + "' parsing local params '" + txt + '"');
}
String val = null;
@@ -148,7 +147,7 @@ public class QueryParsing {
int valStart = p.pos;
for (; ;) {
if (p.pos >= p.end) {
- throw new ParseException("Missing end to unquoted value starting at " + valStart + " str='" + txt + "'");
+ throw new SyntaxError("Missing end to unquoted value starting at " + valStart + " str='" + txt + "'");
}
char c = p.val.charAt(p.pos);
if (c == endChar || Character.isWhitespace(c)) {
@@ -202,7 +201,7 @@ public class QueryParsing {
* "{!prefix f=myfield}yes" returns type="prefix",f="myfield",v="yes"
* "{!prefix f=myfield v=$p}" returns type="prefix",f="myfield",v=params.get("p")
*/
- public static SolrParams getLocalParams(String txt, SolrParams params) throws ParseException {
+ public static SolrParams getLocalParams(String txt, SolrParams params) throws SyntaxError {
if (txt == null || !txt.startsWith(LOCALPARAM_START)) {
return null;
}
@@ -352,7 +351,7 @@ public class QueryParsing {
}
}
- } catch (ParseException e) {
+ } catch (SyntaxError e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "error in sort: " + sortSpec, e);
}
@@ -628,13 +627,13 @@ public class QueryParsing {
}
- void expect(String s) throws ParseException {
+ void expect(String s) throws SyntaxError {
eatws();
int slen = s.length();
if (val.regionMatches(pos, s, 0, slen)) {
pos += slen;
} else {
- throw new ParseException("Expected '" + s + "' at position " + pos + " in '" + val + "'");
+ throw new SyntaxError("Expected '" + s + "' at position " + pos + " in '" + val + "'");
}
}
@@ -723,11 +722,11 @@ public class QueryParsing {
}
- String getId() throws ParseException {
+ String getId() throws SyntaxError {
return getId("Expected identifier");
}
- String getId(String errMessage) throws ParseException {
+ String getId(String errMessage) throws SyntaxError {
eatws();
int id_start = pos;
char ch;
@@ -745,12 +744,12 @@ public class QueryParsing {
}
if (errMessage != null) {
- throw new ParseException(errMessage + " at pos " + pos + " str='" + val + "'");
+ throw new SyntaxError(errMessage + " at pos " + pos + " str='" + val + "'");
}
return null;
}
- public String getGlobbedId(String errMessage) throws ParseException {
+ public String getGlobbedId(String errMessage) throws SyntaxError {
eatws();
int id_start = pos;
char ch;
@@ -767,7 +766,7 @@ public class QueryParsing {
}
if (errMessage != null) {
- throw new ParseException(errMessage + " at pos " + pos + " str='" + val + "'");
+ throw new SyntaxError(errMessage + " at pos " + pos + " str='" + val + "'");
}
return null;
}
@@ -793,7 +792,7 @@ public class QueryParsing {
* sort direction. (True is desc, False is asc).
* Position is advanced to after the comma (or end) when result is non null
*/
- Boolean getSortDirection() throws ParseException {
+ Boolean getSortDirection() throws SyntaxError {
final int startPos = pos;
final String order = getId(null);
@@ -823,7 +822,7 @@ public class QueryParsing {
}
// return null if not a string
- String getQuotedString() throws ParseException {
+ String getQuotedString() throws SyntaxError {
eatws();
char delim = peekChar();
if (!(delim == '\"' || delim == '\'')) {
@@ -833,7 +832,7 @@ public class QueryParsing {
StringBuilder sb = new StringBuilder(); // needed for escaping
for (; ;) {
if (pos >= end) {
- throw new ParseException("Missing end quote for string at pos " + (val_start - 1) + " str='" + val + "'");
+ throw new SyntaxError("Missing end quote for string at pos " + (val_start - 1) + " str='" + val + "'");
}
char ch = val.charAt(pos);
if (ch == '\\') {
@@ -858,7 +857,7 @@ public class QueryParsing {
break;
case 'u':
if (pos + 4 >= end) {
- throw new ParseException("bad unicode escape \\uxxxx at pos" + (val_start - 1) + " str='" + val + "'");
+ throw new SyntaxError("bad unicode escape \\uxxxx at pos" + (val_start - 1) + " str='" + val + "'");
}
ch = (char) Integer.parseInt(val.substring(pos + 1, pos + 5), 16);
pos += 4;
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReturnFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReturnFields.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReturnFields.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ReturnFields.java Fri Nov 23 19:45:50 2012
@@ -22,7 +22,6 @@ import org.apache.commons.io.FilenameUti
import org.apache.lucene.queries.function.FunctionQuery;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.valuesource.QueryValueSource;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CommonParams;
@@ -338,7 +337,7 @@ public class ReturnFields
okFieldNames.add( funcStr );
augmenters.addTransformer( new ValueSourceAugmenter( key, parser, vs ) );
}
- catch (ParseException e) {
+ catch (SyntaxError e) {
// try again, simple rules for a field name with no whitespace
sp.pos = start;
field = sp.getSimpleString();
@@ -357,7 +356,7 @@ public class ReturnFields
// end try as function
} // end for(;;)
- } catch (ParseException e) {
+ } catch (SyntaxError e) {
throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, "Error parsing fieldname", e);
}
}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SolrQueryParser.java Fri Nov 23 19:45:50 2012
@@ -20,12 +20,9 @@ package org.apache.solr.search;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
-import java.util.Map.Entry;
import org.apache.lucene.analysis.util.TokenFilterFactory;
import org.apache.lucene.index.Term;
-import org.apache.lucene.queryparser.classic.ParseException;
-import org.apache.lucene.queryparser.classic.QueryParser;
import org.apache.lucene.search.*;
import org.apache.lucene.util.ToStringUtils;
import org.apache.lucene.util.automaton.Automaton;
@@ -36,6 +33,8 @@ import org.apache.lucene.analysis.Analyz
import org.apache.solr.analysis.ReversedWildcardFilterFactory;
import org.apache.solr.analysis.TokenizerChain;
import org.apache.solr.common.SolrException;
+import org.apache.solr.parser.ParseException;
+import org.apache.solr.parser.QueryParser;
import org.apache.solr.schema.FieldType;
import org.apache.solr.schema.IndexSchema;
import org.apache.solr.schema.SchemaField;
@@ -43,215 +42,12 @@ import org.apache.solr.schema.TextField;
/**
- * A variation on the Lucene QueryParser which knows about the field
- * types and query time analyzers configured in Solr's schema.xml.
- *
- * <p>
- * This class also deviates from the Lucene QueryParser by using
- * ConstantScore versions of RangeQuery and PrefixQuery to prevent
- * TooManyClauses exceptions.
- * </p>
- *
- * <p>
- * If the magic field name "<code>_val_</code>" is used in a term or
- * phrase query, the value is parsed as a function.
- * </p>
+ * Solr's default query parser, a schema-driven superset of the classic lucene query parser.
*/
public class SolrQueryParser extends QueryParser {
- protected final IndexSchema schema;
- protected final QParser parser;
- protected final String defaultField;
-
- /**
- * Identifies the list of all known "magic fields" that trigger
- * special parsing behavior
- */
- public static enum MagicFieldName {
- VAL("_val_", "func"), QUERY("_query_", null);
-
- public final String field;
- public final String subParser;
- MagicFieldName(final String field, final String subParser) {
- this.field = field;
- this.subParser = subParser;
- }
- public String toString() {
- return field;
- }
- private final static Map<String,MagicFieldName> lookup
- = new HashMap<String,MagicFieldName>();
- static {
- for(MagicFieldName s : EnumSet.allOf(MagicFieldName.class))
- lookup.put(s.toString(), s);
- }
- public static MagicFieldName get(final String field) {
- return lookup.get(field);
- }
- }
-
- // implementation detail - caching ReversedWildcardFilterFactory based on type
- private Map<FieldType, ReversedWildcardFilterFactory> leadingWildcards;
public SolrQueryParser(QParser parser, String defaultField) {
- this(parser, defaultField, parser.getReq().getSchema().getQueryAnalyzer());
- }
-
- public SolrQueryParser(QParser parser, String defaultField, Analyzer analyzer) {
- super(parser.getReq().getCore().getSolrConfig().luceneMatchVersion, defaultField, analyzer);
- this.schema = parser.getReq().getSchema();
- this.parser = parser;
- this.defaultField = defaultField;
- setEnablePositionIncrements(true);
- setLowercaseExpandedTerms(false);
- setAllowLeadingWildcard(true);
- }
-
- protected ReversedWildcardFilterFactory getReversedWildcardFilterFactory(FieldType fieldType) {
- if (leadingWildcards == null) leadingWildcards = new HashMap<FieldType, ReversedWildcardFilterFactory>();
- ReversedWildcardFilterFactory fac = leadingWildcards.get(fieldType);
- if (fac == null && leadingWildcards.containsKey(fac)) {
- return fac;
- }
-
- Analyzer a = fieldType.getAnalyzer();
- if (a instanceof TokenizerChain) {
- // examine the indexing analysis chain if it supports leading wildcards
- TokenizerChain tc = (TokenizerChain)a;
- TokenFilterFactory[] factories = tc.getTokenFilterFactories();
- for (TokenFilterFactory factory : factories) {
- if (factory instanceof ReversedWildcardFilterFactory) {
- fac = (ReversedWildcardFilterFactory)factory;
- break;
- }
- }
- }
-
- leadingWildcards.put(fieldType, fac);
- return fac;
- }
-
-
- private void checkNullField(String field) throws SolrException {
- if (field == null && defaultField == null) {
- throw new SolrException
- (SolrException.ErrorCode.BAD_REQUEST,
- "no field name specified in query and no default specified via 'df' param");
- }
- }
-
- protected String analyzeIfMultitermTermText(String field, String part, FieldType fieldType) {
- if (part == null) return part;
-
- SchemaField sf = schema.getFieldOrNull((field));
- if (sf == null || ! (fieldType instanceof TextField)) return part;
- String out = TextField.analyzeMultiTerm(field, part, ((TextField)fieldType).getMultiTermAnalyzer()).utf8ToString();
- // System.out.println("INPUT="+part + " OUTPUT="+out);
- return out;
- }
-
- @Override
- protected Query getFieldQuery(String field, String queryText, boolean quoted) throws ParseException {
- checkNullField(field);
- // intercept magic field name of "_" to use as a hook for our
- // own functions.
- if (field.charAt(0) == '_' && parser != null) {
- MagicFieldName magic = MagicFieldName.get(field);
- if (null != magic) {
- QParser nested = parser.subQuery(queryText, magic.subParser);
- return nested.getQuery();
- }
- }
- SchemaField sf = schema.getFieldOrNull(field);
- if (sf != null) {
- FieldType ft = sf.getType();
- // delegate to type for everything except tokenized fields
- if (ft.isTokenized()) {
- return super.getFieldQuery(field, queryText, quoted || (ft instanceof TextField && ((TextField)ft).getAutoGeneratePhraseQueries()));
- } else {
- return sf.getType().getFieldQuery(parser, sf, queryText);
- }
- }
-
- // default to a normal field query
- return super.getFieldQuery(field, queryText, quoted);
- }
-
- @Override
- protected Query getRangeQuery(String field, String part1, String part2, boolean startInclusive, boolean endInclusive) throws ParseException {
- checkNullField(field);
- SchemaField sf = schema.getField(field);
- return sf.getType().getRangeQuery(parser, sf, part1, part2, startInclusive, endInclusive);
- }
-
- @Override
- protected Query getPrefixQuery(String field, String termStr) throws ParseException {
- checkNullField(field);
-
- termStr = analyzeIfMultitermTermText(field, termStr, schema.getFieldType(field));
-
- // Solr has always used constant scoring for prefix queries. This should return constant scoring by default.
- return newPrefixQuery(new Term(field, termStr));
- }
- @Override
- protected Query getWildcardQuery(String field, String termStr) throws ParseException {
- checkNullField(field);
- // *:* -> MatchAllDocsQuery
- if ("*".equals(field) && "*".equals(termStr)) {
- return newMatchAllDocsQuery();
- }
- FieldType fieldType = schema.getFieldType(field);
- termStr = analyzeIfMultitermTermText(field, termStr, fieldType);
- // can we use reversed wildcards in this field?
- ReversedWildcardFilterFactory factory = getReversedWildcardFilterFactory(fieldType);
- if (factory != null) {
- Term term = new Term(field, termStr);
- // fsa representing the query
- Automaton automaton = WildcardQuery.toAutomaton(term);
- // TODO: we should likely use the automaton to calculate shouldReverse, too.
- if (factory.shouldReverse(termStr)) {
- automaton = BasicOperations.concatenate(automaton, BasicAutomata.makeChar(factory.getMarkerChar()));
- SpecialOperations.reverse(automaton);
- } else {
- // reverse wildcardfilter is active: remove false positives
- // fsa representing false positives (markerChar*)
- Automaton falsePositives = BasicOperations.concatenate(
- BasicAutomata.makeChar(factory.getMarkerChar()),
- BasicAutomata.makeAnyString());
- // subtract these away
- automaton = BasicOperations.minus(automaton, falsePositives);
- }
- return new AutomatonQuery(term, automaton) {
- // override toString so its completely transparent
- @Override
- public String toString(String field) {
- StringBuilder buffer = new StringBuilder();
- if (!getField().equals(field)) {
- buffer.append(getField());
- buffer.append(":");
- }
- buffer.append(term.text());
- buffer.append(ToStringUtils.boost(getBoost()));
- return buffer.toString();
- }
- };
- }
-
- // Solr has always used constant scoring for wildcard queries. This should return constant scoring by default.
- return newWildcardQuery(new Term(field, termStr));
- }
-
- @Override
- protected Query getRegexpQuery(String field, String termStr) throws ParseException
- {
- termStr = analyzeIfMultitermTermText(field, termStr, schema.getFieldType(field));
- return newRegexpQuery(new Term(field, termStr));
- }
-
- @Override
- protected Query getFuzzyQuery(String field, String termStr, float minSimilarity) throws ParseException {
- termStr = analyzeIfMultitermTermText(field, termStr, schema.getFieldType(field));
- Term t = new Term(field, termStr);
- return newFuzzyQuery(t, minSimilarity, getFuzzyPrefixLength());
+ super(parser.getReq().getCore().getSolrConfig().luceneMatchVersion, defaultField, parser);
}
}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SpatialFilterQParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SpatialFilterQParser.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SpatialFilterQParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SpatialFilterQParser.java Fri Nov 23 19:45:50 2012
@@ -17,7 +17,6 @@ package org.apache.solr.search;
*/
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import com.spatial4j.core.distance.DistanceUtils;
import org.apache.solr.common.SolrException;
@@ -44,7 +43,7 @@ public class SpatialFilterQParser extend
@Override
- public Query parse() throws ParseException {
+ public Query parse() throws SyntaxError {
//if more than one, we need to treat them as a point...
//TODO: Should we accept multiple fields
String[] fields = localParams.getParams("f");
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SurroundQParserPlugin.java Fri Nov 23 19:45:50 2012
@@ -18,12 +18,10 @@ package org.apache.solr.search;
*/
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.solr.common.params.CommonParams;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
-import org.apache.solr.handler.SnapPuller;
import org.apache.solr.request.SolrQueryRequest;
import org.apache.lucene.queryparser.surround.parser.*;
import org.apache.lucene.queryparser.surround.query.*;
@@ -74,7 +72,7 @@ class SurroundQParser extends QParser {
@Override
public Query parse()
- throws org.apache.lucene.queryparser.classic.ParseException {
+ throws SyntaxError {
SrndQuery sq;
String qstr = getString();
if (qstr == null)
@@ -95,8 +93,7 @@ class SurroundQParser extends QParser {
sq = org.apache.lucene.queryparser.surround.parser.QueryParser
.parse(qstr);
} catch (org.apache.lucene.queryparser.surround.parser.ParseException pe) {
- throw new org.apache.lucene.queryparser.classic.ParseException(
- pe.getMessage());
+ throw new SyntaxError(pe);
}
// so what do we do with the SrndQuery ??
Added: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SyntaxError.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SyntaxError.java?rev=1413042&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SyntaxError.java (added)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/SyntaxError.java Fri Nov 23 19:45:50 2012
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.search;
+
+/** Simple checked exception for parsing errors */
+public class SyntaxError extends Exception {
+ public SyntaxError(String msg) {
+ super(msg);
+ }
+ public SyntaxError(String msg, Throwable cause) {
+ super(msg, cause);
+ }
+ public SyntaxError(Throwable cause) {
+ super(cause);
+ }
+}
Modified: lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java?rev=1413042&r1=1413041&r2=1413042&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java (original)
+++ lucene/dev/trunk/solr/core/src/java/org/apache/solr/search/ValueSourceParser.java Fri Nov 23 19:45:50 2012
@@ -26,7 +26,6 @@ import org.apache.lucene.queries.functio
import org.apache.lucene.queries.function.docvalues.DoubleDocValues;
import org.apache.lucene.queries.function.docvalues.LongDocValues;
import org.apache.lucene.queries.function.valuesource.*;
-import org.apache.lucene.queryparser.classic.ParseException;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.SortField;
@@ -61,7 +60,7 @@ public abstract class ValueSourceParser
/**
* Parse the user input into a ValueSource.
*/
- public abstract ValueSource parse(FunctionQParser fp) throws ParseException;
+ public abstract ValueSource parse(FunctionQParser fp) throws SyntaxError;
/* standard functions */
public static Map<String, ValueSourceParser> standardValueSourceParsers = new HashMap<String, ValueSourceParser>();
@@ -87,33 +86,33 @@ public abstract class ValueSourceParser
static {
addParser("testfunc", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
final ValueSource source = fp.parseValueSource();
return new TestValueSource(source);
}
});
addParser("ord", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
String field = fp.parseId();
return new OrdFieldSource(field);
}
});
addParser("literal", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
return new LiteralValueSource(fp.parseArg());
}
});
addParser("threadid", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
return new LongConstValueSource(Thread.currentThread().getId());
}
});
addParser("sleep", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
int ms = fp.parseInt();
ValueSource source = fp.parseValueSource();
try {
@@ -126,14 +125,14 @@ public abstract class ValueSourceParser
});
addParser("rord", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
String field = fp.parseId();
return new ReverseOrdFieldSource(field);
}
});
addParser("top", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
// top(vs) is now a no-op
ValueSource source = fp.parseValueSource();
return source;
@@ -141,7 +140,7 @@ public abstract class ValueSourceParser
});
addParser("linear", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource source = fp.parseValueSource();
float slope = fp.parseFloat();
float intercept = fp.parseFloat();
@@ -150,7 +149,7 @@ public abstract class ValueSourceParser
});
addParser("recip", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource source = fp.parseValueSource();
float m = fp.parseFloat();
float a = fp.parseFloat();
@@ -160,7 +159,7 @@ public abstract class ValueSourceParser
});
addParser("scale", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource source = fp.parseValueSource();
float min = fp.parseFloat();
float max = fp.parseFloat();
@@ -169,7 +168,7 @@ public abstract class ValueSourceParser
});
addParser("div", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource a = fp.parseValueSource();
ValueSource b = fp.parseValueSource();
return new DivFloatFunction(a, b);
@@ -177,7 +176,7 @@ public abstract class ValueSourceParser
});
addParser("mod", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource a = fp.parseValueSource();
ValueSource b = fp.parseValueSource();
return new DualFloatFunction(a, b) {
@@ -194,7 +193,7 @@ public abstract class ValueSourceParser
});
addParser("map", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource source = fp.parseValueSource();
float min = fp.parseFloat();
float max = fp.parseFloat();
@@ -206,7 +205,7 @@ public abstract class ValueSourceParser
addParser("abs", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource source = fp.parseValueSource();
return new SimpleFloatFunction(source) {
@Override
@@ -223,7 +222,7 @@ public abstract class ValueSourceParser
});
addParser("sum", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
return new SumFloatFunction(sources.toArray(new ValueSource[sources.size()]));
}
@@ -232,7 +231,7 @@ public abstract class ValueSourceParser
addParser("product", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
return new ProductFloatFunction(sources.toArray(new ValueSource[sources.size()]));
}
@@ -241,7 +240,7 @@ public abstract class ValueSourceParser
addParser("sub", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource a = fp.parseValueSource();
ValueSource b = fp.parseValueSource();
return new DualFloatFunction(a, b) {
@@ -259,14 +258,14 @@ public abstract class ValueSourceParser
});
addParser("vector", new ValueSourceParser(){
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException{
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
return new VectorValueSource(fp.parseValueSourceList());
}
});
addParser("query", new ValueSourceParser() {
// boost(query($q),rating)
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
Query q = fp.parseNestedQuery();
float defVal = 0.0f;
if (fp.hasMoreArguments()) {
@@ -277,7 +276,7 @@ public abstract class ValueSourceParser
});
addParser("boost", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
Query q = fp.parseNestedQuery();
ValueSource vs = fp.parseValueSource();
BoostedQuery bq = new BoostedQuery(q, vs);
@@ -286,7 +285,7 @@ public abstract class ValueSourceParser
});
addParser("joindf", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
String f0 = fp.parseArg();
String qf = fp.parseArg();
return new JoinDocFreqValueSource( f0, qf );
@@ -297,7 +296,7 @@ public abstract class ValueSourceParser
addParser("hsin", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
double radius = fp.parseDouble();
//SOLR-2114, make the convert flag required, since the parser doesn't support much in the way of lookahead or the ability to convert a String into a ValueSource
@@ -338,7 +337,7 @@ public abstract class ValueSourceParser
addParser("ghhsin", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
double radius = fp.parseDouble();
ValueSource gh1 = fp.parseValueSource();
@@ -350,7 +349,7 @@ public abstract class ValueSourceParser
addParser("geohash", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource lat = fp.parseValueSource();
ValueSource lon = fp.parseValueSource();
@@ -360,7 +359,7 @@ public abstract class ValueSourceParser
});
addParser("strdist", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource str1 = fp.parseValueSource();
ValueSource str2 = fp.parseValueSource();
@@ -385,7 +384,7 @@ public abstract class ValueSourceParser
});
addParser("field", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
String fieldName = fp.parseArg();
SchemaField f = fp.getReq().getSchema().getField(fieldName);
@@ -527,21 +526,21 @@ public abstract class ValueSourceParser
});
addParser("max", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
return new MaxFloatFunction(sources.toArray(new ValueSource[sources.size()]));
}
});
addParser("min", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
return new MinFloatFunction(sources.toArray(new ValueSource[sources.size()]));
}
});
addParser("sqedist", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
MVResult mvr = getMultiValueSources(sources);
@@ -551,7 +550,7 @@ public abstract class ValueSourceParser
addParser("dist", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
float power = fp.parseFloat();
List<ValueSource> sources = fp.parseValueSourceList();
MVResult mvr = getMultiValueSources(sources);
@@ -577,7 +576,7 @@ public abstract class ValueSourceParser
addParser("docfreq", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
TInfo tinfo = parseTerm(fp);
return new DocFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
}
@@ -585,7 +584,7 @@ public abstract class ValueSourceParser
addParser("totaltermfreq", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
TInfo tinfo = parseTerm(fp);
return new TotalTermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
}
@@ -594,7 +593,7 @@ public abstract class ValueSourceParser
addParser("sumtotaltermfreq", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
String field = fp.parseArg();
return new SumTotalTermFreqValueSource(field);
}
@@ -603,7 +602,7 @@ public abstract class ValueSourceParser
addParser("idf", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
TInfo tinfo = parseTerm(fp);
return new IDFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
}
@@ -611,7 +610,7 @@ public abstract class ValueSourceParser
addParser("termfreq", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
TInfo tinfo = parseTerm(fp);
return new TermFreqValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
}
@@ -619,7 +618,7 @@ public abstract class ValueSourceParser
addParser("tf", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
TInfo tinfo = parseTerm(fp);
return new TFValueSource(tinfo.field, tinfo.val, tinfo.indexedField, tinfo.indexedBytes);
}
@@ -627,7 +626,7 @@ public abstract class ValueSourceParser
addParser("norm", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
String field = fp.parseArg();
return new NormValueSource(field);
}
@@ -663,7 +662,7 @@ public abstract class ValueSourceParser
addParser("exists", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource vs = fp.parseValueSource();
return new SimpleBoolFunction(vs) {
@Override
@@ -680,7 +679,7 @@ public abstract class ValueSourceParser
addParser("not", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource vs = fp.parseValueSource();
return new SimpleBoolFunction(vs) {
@Override
@@ -698,7 +697,7 @@ public abstract class ValueSourceParser
addParser("and", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
return new MultiBoolFunction(sources) {
@Override
@@ -717,7 +716,7 @@ public abstract class ValueSourceParser
addParser("or", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
return new MultiBoolFunction(sources) {
@Override
@@ -736,7 +735,7 @@ public abstract class ValueSourceParser
addParser("xor", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
List<ValueSource> sources = fp.parseValueSourceList();
return new MultiBoolFunction(sources) {
@Override
@@ -758,7 +757,7 @@ public abstract class ValueSourceParser
addParser("if", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
ValueSource ifValueSource = fp.parseValueSource();
ValueSource trueValueSource = fp.parseValueSource();
ValueSource falseValueSource = fp.parseValueSource();
@@ -769,14 +768,14 @@ public abstract class ValueSourceParser
addParser("def", new ValueSourceParser() {
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
return new DefFunction(fp.parseValueSourceList());
}
});
}
- private static TInfo parseTerm(FunctionQParser fp) throws ParseException {
+ private static TInfo parseTerm(FunctionQParser fp) throws SyntaxError {
TInfo tinfo = new TInfo();
tinfo.indexedField = tinfo.field = fp.parseArg();
@@ -888,7 +887,7 @@ class DateValueSourceParser extends Valu
}
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
String first = fp.parseArg();
String second = fp.parseArg();
if (first == null) first = "NOW";
@@ -1079,7 +1078,7 @@ abstract class DoubleParser extends Name
public abstract double func(int doc, FunctionValues vals);
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
return new Function(fp.parseValueSource());
}
@@ -1119,7 +1118,7 @@ abstract class Double2Parser extends Nam
public abstract double func(int doc, FunctionValues a, FunctionValues b);
@Override
- public ValueSource parse(FunctionQParser fp) throws ParseException {
+ public ValueSource parse(FunctionQParser fp) throws SyntaxError {
return new Function(fp.parseValueSource(), fp.parseValueSource());
}