Skip to content

Commit

Permalink
Changed common terms query to also support camelCased parameters
Browse files Browse the repository at this point in the history
and renamed disable_coords to disable_coord, to be consistent with
the bool query

Closes #3074
  • Loading branch information
clintongormley committed May 22, 2013
1 parent 927fda8 commit bb9871b
Showing 1 changed file with 10 additions and 10 deletions.
Expand Up @@ -48,15 +48,15 @@
public class CommonTermsQueryParser implements QueryParser {

public static final String NAME = "common";

static final float DEFAULT_MAX_TERM_DOC_FREQ = 0.01f;

static final Occur DEFAULT_HIGH_FREQ_OCCUR = Occur.MUST;

static final Occur DEFAULT_LOW_FREQ_OCCUR = Occur.MUST;

static final boolean DEFAULT_DISABLE_COORDS = true;


@Inject
public CommonTermsQueryParser() {
Expand Down Expand Up @@ -98,11 +98,11 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
throw new QueryParsingException(parseContext.index(), "[common] analyzer [" + parser.text() + "] not found");
}
queryAnalyzer = analyzer;
} else if ("disable_coords".equals(currentFieldName)) {
} else if ("disable_coord".equals(currentFieldName) || "disableCoord".equals(currentFieldName)) {
disableCoords = parser.booleanValue();
} else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue();
} else if ("high_freq_operator".equals(currentFieldName)) {
} else if ("high_freq_operator".equals(currentFieldName) || "highFreqOperator".equals(currentFieldName)) {
String op = parser.text();
if ("or".equalsIgnoreCase(op)) {
highFreqOccur = BooleanClause.Occur.SHOULD;
Expand All @@ -112,7 +112,7 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
throw new QueryParsingException(parseContext.index(),
"[common] query requires operator to be either 'and' or 'or', not [" + op + "]");
}
} else if ("low_freq_operator".equals(currentFieldName)) {
} else if ("low_freq_operator".equals(currentFieldName) || "lowFreqOperator".equals(currentFieldName)) {
String op = parser.text();
if ("or".equalsIgnoreCase(op)) {
lowFreqOccur = BooleanClause.Occur.SHOULD;
Expand Down Expand Up @@ -150,11 +150,11 @@ public Query parse(QueryParseContext parseContext) throws IOException, QueryPars
query.setBoost(boost);
return parseQueryString(query, value.toString(), fieldName, parseContext, queryAnalyzer, minimumShouldMatch);
}


private final Query parseQueryString(ExtendedCommonTermsQuery query, String queryString, String fieldName, QueryParseContext parseContext,
String queryAnalyzer, String minimumShouldMatch) throws IOException {

FieldMapper<?> mapper = null;
String field;
MapperService.SmartNameFieldMappers smartNameFieldMappers = parseContext.smartFieldMappers(fieldName);
Expand Down Expand Up @@ -195,7 +195,7 @@ private final Query parseQueryString(ExtendedCommonTermsQuery query, String quer
query.add(new Term(field, ref));
count++;
}

if (count == 0) {
return null;
}
Expand Down

0 comments on commit bb9871b

Please sign in to comment.