Query DSL: Allow for CamelCase field names, closes #134.
This commit is contained in:
parent
2d6de97069
commit
fcb99b4d9b
|
@ -63,7 +63,7 @@ public class BoolJsonFilterParser extends AbstractIndexComponent implements Json
|
||||||
} else if (token == JsonToken.START_OBJECT) {
|
} else if (token == JsonToken.START_OBJECT) {
|
||||||
if ("must".equals(currentFieldName)) {
|
if ("must".equals(currentFieldName)) {
|
||||||
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.MUST));
|
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.MUST));
|
||||||
} else if ("must_not".equals(currentFieldName)) {
|
} else if ("must_not".equals(currentFieldName) || "mustNot".equals(currentFieldName)) {
|
||||||
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.MUST_NOT));
|
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.MUST_NOT));
|
||||||
} else if ("should".equals(currentFieldName)) {
|
} else if ("should".equals(currentFieldName)) {
|
||||||
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.SHOULD));
|
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.SHOULD));
|
||||||
|
@ -73,7 +73,7 @@ public class BoolJsonFilterParser extends AbstractIndexComponent implements Json
|
||||||
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
||||||
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.MUST));
|
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.MUST));
|
||||||
}
|
}
|
||||||
} else if ("must_not".equals(currentFieldName)) {
|
} else if ("must_not".equals(currentFieldName) || "mustNot".equals(currentFieldName)) {
|
||||||
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
||||||
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.MUST_NOT));
|
clauses.add(new FilterClause(parseContext.parseInnerFilter(), BooleanClause.Occur.MUST_NOT));
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@ public class BoolJsonQueryParser extends AbstractIndexComponent implements JsonQ
|
||||||
} else if (token == JsonToken.START_OBJECT) {
|
} else if (token == JsonToken.START_OBJECT) {
|
||||||
if ("must".equals(currentFieldName)) {
|
if ("must".equals(currentFieldName)) {
|
||||||
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.MUST));
|
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.MUST));
|
||||||
} else if ("must_not".equals(currentFieldName)) {
|
} else if ("must_not".equals(currentFieldName) || "mustNot".equals(currentFieldName)) {
|
||||||
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.MUST_NOT));
|
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.MUST_NOT));
|
||||||
} else if ("should".equals(currentFieldName)) {
|
} else if ("should".equals(currentFieldName)) {
|
||||||
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.SHOULD));
|
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.SHOULD));
|
||||||
|
@ -78,7 +78,7 @@ public class BoolJsonQueryParser extends AbstractIndexComponent implements JsonQ
|
||||||
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
||||||
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.MUST));
|
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.MUST));
|
||||||
}
|
}
|
||||||
} else if ("must_not".equals(currentFieldName)) {
|
} else if ("must_not".equals(currentFieldName) || "mustNot".equals(currentFieldName)) {
|
||||||
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
||||||
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.MUST_NOT));
|
clauses.add(new BooleanClause(parseContext.parseInnerQuery(), BooleanClause.Occur.MUST_NOT));
|
||||||
}
|
}
|
||||||
|
@ -88,13 +88,13 @@ public class BoolJsonQueryParser extends AbstractIndexComponent implements JsonQ
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_TRUE || token == JsonToken.VALUE_FALSE) {
|
} else if (token == JsonToken.VALUE_TRUE || token == JsonToken.VALUE_FALSE) {
|
||||||
if ("disable_coord".equals(currentFieldName)) {
|
if ("disable_coord".equals(currentFieldName) || "disableCoord".equals(currentFieldName)) {
|
||||||
disableCoord = token == JsonToken.VALUE_TRUE;
|
disableCoord = token == JsonToken.VALUE_TRUE;
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
if ("disable_coord".equals(currentFieldName)) {
|
if ("disable_coord".equals(currentFieldName) || "disableCoord".equals(currentFieldName)) {
|
||||||
disableCoord = jp.getIntValue() != 0;
|
disableCoord = jp.getIntValue() != 0;
|
||||||
} else if ("minimum_number_should_match".equals(currentFieldName)) {
|
} else if ("minimum_number_should_match".equals(currentFieldName) || "minimumNumberShouldMatch".equals(currentFieldName)) {
|
||||||
minimumNumberShouldMatch = jp.getIntValue();
|
minimumNumberShouldMatch = jp.getIntValue();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getIntValue();
|
boost = jp.getIntValue();
|
||||||
|
@ -104,9 +104,9 @@ public class BoolJsonQueryParser extends AbstractIndexComponent implements JsonQ
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("disable_coord".equals(currentFieldName)) {
|
if ("disable_coord".equals(currentFieldName) || "disableCoord".equals(currentFieldName)) {
|
||||||
disableCoord = Booleans.parseBoolean(jp.getText(), false);
|
disableCoord = Booleans.parseBoolean(jp.getText(), false);
|
||||||
} else if ("minimum_number_should_match".equals(currentFieldName)) {
|
} else if ("minimum_number_should_match".equals(currentFieldName) || "minimumNumberShouldMatch".equals(currentFieldName)) {
|
||||||
minimumNumberShouldMatch = Integer.parseInt(jp.getText());
|
minimumNumberShouldMatch = Integer.parseInt(jp.getText());
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = Float.parseFloat(jp.getText());
|
boost = Float.parseFloat(jp.getText());
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -47,7 +48,7 @@ public class DisMaxJsonQueryParser extends AbstractIndexComponent implements Jso
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME};
|
return new String[]{NAME, Strings.toCamelCase(NAME)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
@ -81,7 +82,7 @@ public class DisMaxJsonQueryParser extends AbstractIndexComponent implements Jso
|
||||||
} else {
|
} else {
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
}
|
}
|
||||||
} else if ("tie_breaker".equals(currentFieldName)) {
|
} else if ("tie_breaker".equals(currentFieldName) || "tieBreaker".equals(currentFieldName)) {
|
||||||
if (token == JsonToken.VALUE_STRING) {
|
if (token == JsonToken.VALUE_STRING) {
|
||||||
tieBreaker = Float.parseFloat(jp.getText());
|
tieBreaker = Float.parseFloat(jp.getText());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -86,15 +86,15 @@ public class FieldJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
queryString = jp.getText();
|
queryString = jp.getText();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = Float.parseFloat(jp.getText());
|
boost = Float.parseFloat(jp.getText());
|
||||||
} else if ("enable_position_increments".equals(currentFieldName)) {
|
} else if ("enable_position_increments".equals(currentFieldName) || "enablePositionIncrements".equals(currentFieldName)) {
|
||||||
enablePositionIncrements = Booleans.parseBoolean(jp.getText(), true);
|
enablePositionIncrements = Booleans.parseBoolean(jp.getText(), true);
|
||||||
} else if ("lowercase_expanded_terms".equals(currentFieldName)) {
|
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||||
lowercaseExpandedTerms = Booleans.parseBoolean(jp.getText(), true);
|
lowercaseExpandedTerms = Booleans.parseBoolean(jp.getText(), true);
|
||||||
} else if ("phrase_slop".equals(currentFieldName)) {
|
} else if ("phrase_slop".equals(currentFieldName) || "phraseSlop".equals(currentFieldName)) {
|
||||||
phraseSlop = Integer.parseInt(jp.getText());
|
phraseSlop = Integer.parseInt(jp.getText());
|
||||||
} else if ("analyzer".equals(currentFieldName)) {
|
} else if ("analyzer".equals(currentFieldName)) {
|
||||||
analyzer = analysisService.analyzer(jp.getText());
|
analyzer = analysisService.analyzer(jp.getText());
|
||||||
} else if ("default_operator".equals(currentFieldName)) {
|
} else if ("default_operator".equals(currentFieldName) || "defaultOperator".equals(currentFieldName)) {
|
||||||
String op = jp.getText();
|
String op = jp.getText();
|
||||||
if ("or".equalsIgnoreCase(op)) {
|
if ("or".equalsIgnoreCase(op)) {
|
||||||
defaultOperator = QueryParser.Operator.OR;
|
defaultOperator = QueryParser.Operator.OR;
|
||||||
|
@ -103,9 +103,9 @@ public class FieldJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
} else {
|
} else {
|
||||||
throw new QueryParsingException(index, "Query default operator [" + op + "] is not allowed");
|
throw new QueryParsingException(index, "Query default operator [" + op + "] is not allowed");
|
||||||
}
|
}
|
||||||
} else if ("fuzzy_min_sim".equals(currentFieldName)) {
|
} else if ("fuzzy_min_sim".equals(currentFieldName) || "fuzzyMinSim".equals(currentFieldName)) {
|
||||||
fuzzyMinSim = Float.parseFloat(jp.getText());
|
fuzzyMinSim = Float.parseFloat(jp.getText());
|
||||||
} else if ("fuzzy_prefix_length".equals(currentFieldName)) {
|
} else if ("fuzzy_prefix_length".equals(currentFieldName) || "fuzzyPrefixLength".equals(currentFieldName)) {
|
||||||
fuzzyPrefixLength = Integer.parseInt(jp.getText());
|
fuzzyPrefixLength = Integer.parseInt(jp.getText());
|
||||||
} else if ("escape".equals(currentFieldName)) {
|
} else if ("escape".equals(currentFieldName)) {
|
||||||
escape = Booleans.parseBoolean(jp.getText(), false);
|
escape = Booleans.parseBoolean(jp.getText(), false);
|
||||||
|
@ -115,15 +115,15 @@ public class FieldJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
queryString = jp.getText();
|
queryString = jp.getText();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getIntValue();
|
boost = jp.getIntValue();
|
||||||
} else if ("enable_position_increments".equals(currentFieldName)) {
|
} else if ("enable_position_increments".equals(currentFieldName) || "enablePositionIncrements".equals(currentFieldName)) {
|
||||||
enablePositionIncrements = jp.getIntValue() != 0;
|
enablePositionIncrements = jp.getIntValue() != 0;
|
||||||
} else if ("lowercase_expanded_terms".equals(currentFieldName)) {
|
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||||
lowercaseExpandedTerms = jp.getIntValue() != 0;
|
lowercaseExpandedTerms = jp.getIntValue() != 0;
|
||||||
} else if ("phrase_slop".equals(currentFieldName)) {
|
} else if ("phrase_slop".equals(currentFieldName) || "phraseSlop".equals(currentFieldName)) {
|
||||||
phraseSlop = jp.getIntValue();
|
phraseSlop = jp.getIntValue();
|
||||||
} else if ("fuzzy_min_sim".equals(currentFieldName)) {
|
} else if ("fuzzy_min_sim".equals(currentFieldName) || "fuzzyMinSim".equals(currentFieldName)) {
|
||||||
fuzzyMinSim = jp.getIntValue();
|
fuzzyMinSim = jp.getIntValue();
|
||||||
} else if ("fuzzy_prefix_length".equals(currentFieldName)) {
|
} else if ("fuzzy_prefix_length".equals(currentFieldName) || "fuzzyPrefixLength".equals(currentFieldName)) {
|
||||||
fuzzyPrefixLength = jp.getIntValue();
|
fuzzyPrefixLength = jp.getIntValue();
|
||||||
} else if ("escape".equals(currentFieldName)) {
|
} else if ("escape".equals(currentFieldName)) {
|
||||||
escape = jp.getIntValue() != 0;
|
escape = jp.getIntValue() != 0;
|
||||||
|
@ -133,15 +133,15 @@ public class FieldJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
queryString = jp.getText();
|
queryString = jp.getText();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
} else if ("fuzzy_prefix_length".equals(currentFieldName)) {
|
} else if ("fuzzy_prefix_length".equals(currentFieldName) || "fuzzyPrefixLength".equals(currentFieldName)) {
|
||||||
fuzzyPrefixLength = jp.getIntValue();
|
fuzzyPrefixLength = jp.getIntValue();
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_TRUE) {
|
} else if (token == JsonToken.VALUE_TRUE) {
|
||||||
if ("query".equals(currentFieldName)) {
|
if ("query".equals(currentFieldName)) {
|
||||||
queryString = jp.getText();
|
queryString = jp.getText();
|
||||||
} else if ("enable_position_increments".equals(currentFieldName)) {
|
} else if ("enable_position_increments".equals(currentFieldName) || "enablePositionIncrements".equals(currentFieldName)) {
|
||||||
enablePositionIncrements = true;
|
enablePositionIncrements = true;
|
||||||
} else if ("lowercase_expanded_terms".equals(currentFieldName)) {
|
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||||
lowercaseExpandedTerms = true;
|
lowercaseExpandedTerms = true;
|
||||||
} else if ("escape".equals(currentFieldName)) {
|
} else if ("escape".equals(currentFieldName)) {
|
||||||
escape = true;
|
escape = true;
|
||||||
|
@ -149,9 +149,9 @@ public class FieldJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
} else if (token == JsonToken.VALUE_FALSE) {
|
} else if (token == JsonToken.VALUE_FALSE) {
|
||||||
if ("query".equals(currentFieldName)) {
|
if ("query".equals(currentFieldName)) {
|
||||||
queryString = jp.getText();
|
queryString = jp.getText();
|
||||||
} else if ("enable_position_increments".equals(currentFieldName)) {
|
} else if ("enable_position_increments".equals(currentFieldName) || "enablePositionIncrements".equals(currentFieldName)) {
|
||||||
enablePositionIncrements = false;
|
enablePositionIncrements = false;
|
||||||
} else if ("lowercase_expanded_terms".equals(currentFieldName)) {
|
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||||
lowercaseExpandedTerms = false;
|
lowercaseExpandedTerms = false;
|
||||||
} else if ("escape".equals(currentFieldName)) {
|
} else if ("escape".equals(currentFieldName)) {
|
||||||
escape = false;
|
escape = false;
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
import org.elasticsearch.util.Booleans;
|
import org.elasticsearch.util.Booleans;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -59,7 +60,7 @@ public class FuzzyLikeThisFieldJsonQueryParser extends AbstractIndexComponent im
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME, "fuzzy_like_this_field"};
|
return new String[]{NAME, "fuzzy_like_this_field", Strings.toCamelCase(NAME), "fuzzyLikeThisField"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
@ -86,25 +87,25 @@ public class FuzzyLikeThisFieldJsonQueryParser extends AbstractIndexComponent im
|
||||||
if (token == JsonToken.FIELD_NAME) {
|
if (token == JsonToken.FIELD_NAME) {
|
||||||
currentFieldName = jp.getCurrentName();
|
currentFieldName = jp.getCurrentName();
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("like_text".equals(currentFieldName)) {
|
if ("like_text".equals(currentFieldName) || "likeText".equals(currentFieldName)) {
|
||||||
likeText = jp.getText();
|
likeText = jp.getText();
|
||||||
} else if ("max_query_terms".equals(currentFieldName)) {
|
} else if ("max_query_terms".equals(currentFieldName) || "maxQueryTerms".equals(currentFieldName)) {
|
||||||
maxNumTerms = Integer.parseInt(jp.getText());
|
maxNumTerms = Integer.parseInt(jp.getText());
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = Float.parseFloat(jp.getText());
|
boost = Float.parseFloat(jp.getText());
|
||||||
} else if ("ignore_tf".equals(currentFieldName)) {
|
} else if ("ignore_tf".equals(currentFieldName) || "ignoreTF".equals(currentFieldName)) {
|
||||||
ignoreTF = Booleans.parseBoolean(jp.getText(), false);
|
ignoreTF = Booleans.parseBoolean(jp.getText(), false);
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
if ("max_query_terms".equals(currentFieldName)) {
|
if ("max_query_terms".equals(currentFieldName) || "maxQueryTerms".equals(currentFieldName)) {
|
||||||
maxNumTerms = jp.getIntValue();
|
maxNumTerms = jp.getIntValue();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getIntValue();
|
boost = jp.getIntValue();
|
||||||
} else if ("ignore_tf".equals(currentFieldName)) {
|
} else if ("ignore_tf".equals(currentFieldName) || "ignoreTF".equals(currentFieldName)) {
|
||||||
ignoreTF = jp.getIntValue() != 0;
|
ignoreTF = jp.getIntValue() != 0;
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_TRUE) {
|
} else if (token == JsonToken.VALUE_TRUE) {
|
||||||
if ("ignore_tf".equals(currentFieldName)) {
|
if ("ignore_tf".equals(currentFieldName) || "ignoreTF".equals(currentFieldName)) {
|
||||||
ignoreTF = true;
|
ignoreTF = true;
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
||||||
|
@ -115,7 +116,7 @@ public class FuzzyLikeThisFieldJsonQueryParser extends AbstractIndexComponent im
|
||||||
}
|
}
|
||||||
|
|
||||||
if (likeText == null) {
|
if (likeText == null) {
|
||||||
throw new QueryParsingException(index, "fuzzy_like_This_field requires 'likeText' to be specified");
|
throw new QueryParsingException(index, "fuzzy_like_This_field requires 'like_text' to be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
Analyzer analyzer = null;
|
Analyzer analyzer = null;
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class FuzzyLikeThisJsonQueryParser extends AbstractIndexComponent impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME, "fuzzy_like_this"};
|
return new String[]{NAME, "fuzzy_like_this", "fuzzyLikeThis"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
@ -78,25 +78,25 @@ public class FuzzyLikeThisJsonQueryParser extends AbstractIndexComponent impleme
|
||||||
if (token == JsonToken.FIELD_NAME) {
|
if (token == JsonToken.FIELD_NAME) {
|
||||||
currentFieldName = jp.getCurrentName();
|
currentFieldName = jp.getCurrentName();
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("like_text".equals(currentFieldName)) {
|
if ("like_text".equals(currentFieldName) || "likeText".equals(currentFieldName)) {
|
||||||
likeText = jp.getText();
|
likeText = jp.getText();
|
||||||
} else if ("max_query_terms".equals(currentFieldName)) {
|
} else if ("max_query_terms".equals(currentFieldName) || "maxQueryTerms".equals(currentFieldName)) {
|
||||||
maxNumTerms = Integer.parseInt(jp.getText());
|
maxNumTerms = Integer.parseInt(jp.getText());
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = Float.parseFloat(jp.getText());
|
boost = Float.parseFloat(jp.getText());
|
||||||
} else if ("ignore_tf".equals(currentFieldName)) {
|
} else if ("ignore_tf".equals(currentFieldName) || "ignoreTF".equals(currentFieldName)) {
|
||||||
ignoreTF = Booleans.parseBoolean(jp.getText(), false);
|
ignoreTF = Booleans.parseBoolean(jp.getText(), false);
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
if ("max_query_terms".equals(currentFieldName)) {
|
if ("max_query_terms".equals(currentFieldName) || "maxQueryTerms".equals(currentFieldName)) {
|
||||||
maxNumTerms = jp.getIntValue();
|
maxNumTerms = jp.getIntValue();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getIntValue();
|
boost = jp.getIntValue();
|
||||||
} else if ("ignore_tf".equals(currentFieldName)) {
|
} else if ("ignore_tf".equals(currentFieldName) || "ignoreTF".equals(currentFieldName)) {
|
||||||
ignoreTF = jp.getIntValue() != 0;
|
ignoreTF = jp.getIntValue() != 0;
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_TRUE) {
|
} else if (token == JsonToken.VALUE_TRUE) {
|
||||||
if ("ignore_tf".equals(currentFieldName)) {
|
if ("ignore_tf".equals(currentFieldName) || "ignoreTF".equals(currentFieldName)) {
|
||||||
ignoreTF = true;
|
ignoreTF = true;
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
||||||
|
@ -114,7 +114,7 @@ public class FuzzyLikeThisJsonQueryParser extends AbstractIndexComponent impleme
|
||||||
}
|
}
|
||||||
|
|
||||||
if (likeText == null) {
|
if (likeText == null) {
|
||||||
throw new QueryParsingException(index, "fuzzy_like_this requires 'likeText' to be specified");
|
throw new QueryParsingException(index, "fuzzy_like_this requires 'like_text' to be specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
FuzzyLikeThisQuery query = new FuzzyLikeThisQuery(maxNumTerms, parseContext.mapperService().searchAnalyzer());
|
FuzzyLikeThisQuery query = new FuzzyLikeThisQuery(maxNumTerms, parseContext.mapperService().searchAnalyzer());
|
||||||
|
|
|
@ -36,7 +36,7 @@ import org.elasticsearch.util.Nullable;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author kimchy (Shay Banon)
|
* @author kimchy (shay.banon)
|
||||||
*/
|
*/
|
||||||
public class JsonQueryParseContext {
|
public class JsonQueryParseContext {
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
package org.elasticsearch.index.query.json;
|
package org.elasticsearch.index.query.json;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
|
import org.apache.lucene.util.StringHelper;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.analysis.AnalysisService;
|
import org.elasticsearch.index.analysis.AnalysisService;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
@ -103,13 +104,13 @@ public class JsonQueryParserRegistry {
|
||||||
|
|
||||||
private void add(Map<String, JsonFilterParser> map, JsonFilterParser filterParser) {
|
private void add(Map<String, JsonFilterParser> map, JsonFilterParser filterParser) {
|
||||||
for (String name : filterParser.names()) {
|
for (String name : filterParser.names()) {
|
||||||
map.put(name, filterParser);
|
map.put(StringHelper.intern(name), filterParser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void add(Map<String, JsonQueryParser> map, JsonQueryParser jsonQueryParser) {
|
private void add(Map<String, JsonQueryParser> map, JsonQueryParser jsonQueryParser) {
|
||||||
for (String name : jsonQueryParser.names()) {
|
for (String name : jsonQueryParser.names()) {
|
||||||
map.put(name, jsonQueryParser);
|
map.put(StringHelper.intern(name), jsonQueryParser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -44,7 +45,7 @@ public class MatchAllJsonQueryParser extends AbstractIndexComponent implements J
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME};
|
return new String[]{NAME, Strings.toCamelCase(NAME)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
@ -61,7 +62,7 @@ public class MatchAllJsonQueryParser extends AbstractIndexComponent implements J
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("boost".equals(currentFieldName)) {
|
if ("boost".equals(currentFieldName)) {
|
||||||
boost = Float.parseFloat(jp.getText());
|
boost = Float.parseFloat(jp.getText());
|
||||||
} else if ("norms_field".equals(currentFieldName)) {
|
} else if ("norms_field".equals(currentFieldName) || "normsField".equals(currentFieldName)) {
|
||||||
normsField = parseContext.indexName(jp.getText());
|
normsField = parseContext.indexName(jp.getText());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -28,6 +28,7 @@ import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.mapper.MapperService;
|
import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.lucene.search.MoreLikeThisQuery;
|
import org.elasticsearch.util.lucene.search.MoreLikeThisQuery;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ public class MoreLikeThisFieldJsonQueryParser extends AbstractIndexComponent imp
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME, "more_like_this_field"};
|
return new String[]{NAME, "more_like_this_field", Strings.toCamelCase(NAME), "moreLikeThisField"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
@ -73,56 +74,56 @@ public class MoreLikeThisFieldJsonQueryParser extends AbstractIndexComponent imp
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("like_text".equals(currentFieldName)) {
|
if ("like_text".equals(currentFieldName)) {
|
||||||
mltQuery.setLikeText(jp.getText());
|
mltQuery.setLikeText(jp.getText());
|
||||||
} else if ("min_term_freq".equals(currentFieldName)) {
|
} else if ("min_term_freq".equals(currentFieldName) || "minTermFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMinTermFrequency(Integer.parseInt(jp.getText()));
|
mltQuery.setMinTermFrequency(Integer.parseInt(jp.getText()));
|
||||||
} else if ("max_query_terms".equals(currentFieldName)) {
|
} else if ("max_query_terms".equals(currentFieldName) || "maxQueryTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxQueryTerms(Integer.parseInt(jp.getText()));
|
mltQuery.setMaxQueryTerms(Integer.parseInt(jp.getText()));
|
||||||
} else if ("min_doc_freq".equals(currentFieldName)) {
|
} else if ("min_doc_freq".equals(currentFieldName) || "minDocFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMinDocFreq(Integer.parseInt(jp.getText()));
|
mltQuery.setMinDocFreq(Integer.parseInt(jp.getText()));
|
||||||
} else if ("max_doc_freq".equals(currentFieldName)) {
|
} else if ("max_doc_freq".equals(currentFieldName) || "maxDocFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxDocFreq(Integer.parseInt(jp.getText()));
|
mltQuery.setMaxDocFreq(Integer.parseInt(jp.getText()));
|
||||||
} else if ("min_word_len".equals(currentFieldName)) {
|
} else if ("min_word_len".equals(currentFieldName) || "minWordLen".equals(currentFieldName)) {
|
||||||
mltQuery.setMinWordLen(Integer.parseInt(jp.getText()));
|
mltQuery.setMinWordLen(Integer.parseInt(jp.getText()));
|
||||||
} else if ("max_word_len".equals(currentFieldName)) {
|
} else if ("max_word_len".equals(currentFieldName) || "maxWordLen".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxWordLen(Integer.parseInt(jp.getText()));
|
mltQuery.setMaxWordLen(Integer.parseInt(jp.getText()));
|
||||||
} else if ("boost_terms".equals(currentFieldName)) {
|
} else if ("boost_terms".equals(currentFieldName) || "boostTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setBoostTerms(true);
|
mltQuery.setBoostTerms(true);
|
||||||
mltQuery.setBoostTermsFactor(Float.parseFloat(jp.getText()));
|
mltQuery.setBoostTermsFactor(Float.parseFloat(jp.getText()));
|
||||||
} else if ("percent_terms_to_match".equals(currentFieldName)) {
|
} else if ("percent_terms_to_match".equals(currentFieldName) || "percentTermsToMatch".equals(currentFieldName)) {
|
||||||
mltQuery.setPercentTermsToMatch(Float.parseFloat(jp.getText()));
|
mltQuery.setPercentTermsToMatch(Float.parseFloat(jp.getText()));
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
if ("min_term_freq".equals(currentFieldName)) {
|
if ("min_term_freq".equals(currentFieldName) || "minTermFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMinTermFrequency(jp.getIntValue());
|
mltQuery.setMinTermFrequency(jp.getIntValue());
|
||||||
} else if ("max_query_terms".equals(currentFieldName)) {
|
} else if ("max_query_terms".equals(currentFieldName) || "maxQueryTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxQueryTerms(jp.getIntValue());
|
mltQuery.setMaxQueryTerms(jp.getIntValue());
|
||||||
} else if ("min_doc_freq".equals(currentFieldName)) {
|
} else if ("min_doc_freq".equals(currentFieldName) || "minDocFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMinDocFreq(jp.getIntValue());
|
mltQuery.setMinDocFreq(jp.getIntValue());
|
||||||
} else if ("max_doc_freq".equals(currentFieldName)) {
|
} else if ("max_doc_freq".equals(currentFieldName) || "maxDocFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxDocFreq(jp.getIntValue());
|
mltQuery.setMaxDocFreq(jp.getIntValue());
|
||||||
} else if ("min_word_len".equals(currentFieldName)) {
|
} else if ("min_word_len".equals(currentFieldName) || "minWordLen".equals(currentFieldName)) {
|
||||||
mltQuery.setMinWordLen(jp.getIntValue());
|
mltQuery.setMinWordLen(jp.getIntValue());
|
||||||
} else if ("max_word_len".equals(currentFieldName)) {
|
} else if ("max_word_len".equals(currentFieldName) || "maxWordLen".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxWordLen(jp.getIntValue());
|
mltQuery.setMaxWordLen(jp.getIntValue());
|
||||||
} else if ("boost_term".equals(currentFieldName)) {
|
} else if ("boost_terms".equals(currentFieldName) || "boostTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setBoostTerms(true);
|
mltQuery.setBoostTerms(true);
|
||||||
mltQuery.setBoostTermsFactor(jp.getIntValue());
|
mltQuery.setBoostTermsFactor(jp.getIntValue());
|
||||||
} else if ("percent_terms_to_match".equals(currentFieldName)) {
|
} else if ("percent_terms_to_match".equals(currentFieldName) || "percentTermsToMatch".equals(currentFieldName)) {
|
||||||
mltQuery.setPercentTermsToMatch(jp.getIntValue());
|
mltQuery.setPercentTermsToMatch(jp.getIntValue());
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
mltQuery.setBoost(jp.getIntValue());
|
mltQuery.setBoost(jp.getIntValue());
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
||||||
if ("boost_terms".equals(currentFieldName)) {
|
if ("boost_terms".equals(currentFieldName) || "boostTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setBoostTerms(true);
|
mltQuery.setBoostTerms(true);
|
||||||
mltQuery.setBoostTermsFactor(jp.getFloatValue());
|
mltQuery.setBoostTermsFactor(jp.getFloatValue());
|
||||||
} else if ("percent_terms_to_match".equals(currentFieldName)) {
|
} else if ("percent_terms_to_match".equals(currentFieldName) || "percentTermsToMatch".equals(currentFieldName)) {
|
||||||
mltQuery.setPercentTermsToMatch(jp.getFloatValue());
|
mltQuery.setPercentTermsToMatch(jp.getFloatValue());
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
mltQuery.setBoost(jp.getFloatValue());
|
mltQuery.setBoost(jp.getFloatValue());
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.START_ARRAY) {
|
} else if (token == JsonToken.START_ARRAY) {
|
||||||
if ("stop_words".equals(currentFieldName)) {
|
if ("stop_words".equals(currentFieldName) || "stopWords".equals(currentFieldName)) {
|
||||||
Set<String> stopWords = Sets.newHashSet();
|
Set<String> stopWords = Sets.newHashSet();
|
||||||
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
||||||
stopWords.add(jp.getText());
|
stopWords.add(jp.getText());
|
||||||
|
|
|
@ -49,7 +49,7 @@ public class MoreLikeThisJsonQueryParser extends AbstractIndexComponent implemen
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME, "more_like_this"};
|
return new String[]{NAME, "more_like_this", "moreLikeThis"};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
@ -65,58 +65,58 @@ public class MoreLikeThisJsonQueryParser extends AbstractIndexComponent implemen
|
||||||
if (token == JsonToken.FIELD_NAME) {
|
if (token == JsonToken.FIELD_NAME) {
|
||||||
currentFieldName = jp.getCurrentName();
|
currentFieldName = jp.getCurrentName();
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("like_text".equals(currentFieldName)) {
|
if ("like_text".equals(currentFieldName) || "likeText".equals(currentFieldName)) {
|
||||||
mltQuery.setLikeText(jp.getText());
|
mltQuery.setLikeText(jp.getText());
|
||||||
} else if ("min_term_freq".equals(currentFieldName)) {
|
} else if ("min_term_freq".equals(currentFieldName) || "minTermFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMinTermFrequency(Integer.parseInt(jp.getText()));
|
mltQuery.setMinTermFrequency(Integer.parseInt(jp.getText()));
|
||||||
} else if ("max_query_terms".equals(currentFieldName)) {
|
} else if ("max_query_terms".equals(currentFieldName) || "maxQueryTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxQueryTerms(Integer.parseInt(jp.getText()));
|
mltQuery.setMaxQueryTerms(Integer.parseInt(jp.getText()));
|
||||||
} else if ("min_doc_freq".equals(currentFieldName)) {
|
} else if ("min_doc_freq".equals(currentFieldName) || "minDocFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMinDocFreq(Integer.parseInt(jp.getText()));
|
mltQuery.setMinDocFreq(Integer.parseInt(jp.getText()));
|
||||||
} else if ("max_doc_freq".equals(currentFieldName)) {
|
} else if ("max_doc_freq".equals(currentFieldName) || "maxDocFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxDocFreq(Integer.parseInt(jp.getText()));
|
mltQuery.setMaxDocFreq(Integer.parseInt(jp.getText()));
|
||||||
} else if ("min_word_len".equals(currentFieldName)) {
|
} else if ("min_word_len".equals(currentFieldName) || "minWordLen".equals(currentFieldName)) {
|
||||||
mltQuery.setMinWordLen(Integer.parseInt(jp.getText()));
|
mltQuery.setMinWordLen(Integer.parseInt(jp.getText()));
|
||||||
} else if ("max_word_len".equals(currentFieldName)) {
|
} else if ("max_word_len".equals(currentFieldName) || "maxWordLen".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxWordLen(Integer.parseInt(jp.getText()));
|
mltQuery.setMaxWordLen(Integer.parseInt(jp.getText()));
|
||||||
} else if ("boost_terms".equals(currentFieldName)) {
|
} else if ("boost_terms".equals(currentFieldName) || "boostTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setBoostTerms(true);
|
mltQuery.setBoostTerms(true);
|
||||||
mltQuery.setBoostTermsFactor(Float.parseFloat(jp.getText()));
|
mltQuery.setBoostTermsFactor(Float.parseFloat(jp.getText()));
|
||||||
} else if ("percent_terms_to_match".equals(currentFieldName)) {
|
} else if ("percent_terms_to_match".equals(currentFieldName) || "percentTermsToMatch".equals(currentFieldName)) {
|
||||||
mltQuery.setPercentTermsToMatch(Float.parseFloat(jp.getText()));
|
mltQuery.setPercentTermsToMatch(Float.parseFloat(jp.getText()));
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
if ("min_term_freq".equals(currentFieldName)) {
|
if ("min_term_freq".equals(currentFieldName) || "minTermFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMinTermFrequency(jp.getIntValue());
|
mltQuery.setMinTermFrequency(jp.getIntValue());
|
||||||
} else if ("max_query_terms".equals(currentFieldName)) {
|
} else if ("max_query_terms".equals(currentFieldName) || "maxQueryTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxQueryTerms(jp.getIntValue());
|
mltQuery.setMaxQueryTerms(jp.getIntValue());
|
||||||
} else if ("min_doc_freq".equals(currentFieldName)) {
|
} else if ("min_doc_freq".equals(currentFieldName) || "minDocFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMinDocFreq(jp.getIntValue());
|
mltQuery.setMinDocFreq(jp.getIntValue());
|
||||||
} else if ("max_doc_freq".equals(currentFieldName)) {
|
} else if ("max_doc_freq".equals(currentFieldName) || "maxDocFreq".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxDocFreq(jp.getIntValue());
|
mltQuery.setMaxDocFreq(jp.getIntValue());
|
||||||
} else if ("min_word_len".equals(currentFieldName)) {
|
} else if ("min_word_len".equals(currentFieldName) || "minWordLen".equals(currentFieldName)) {
|
||||||
mltQuery.setMinWordLen(jp.getIntValue());
|
mltQuery.setMinWordLen(jp.getIntValue());
|
||||||
} else if ("max_word_len".equals(currentFieldName)) {
|
} else if ("max_word_len".equals(currentFieldName) || "maxWordLen".equals(currentFieldName)) {
|
||||||
mltQuery.setMaxWordLen(jp.getIntValue());
|
mltQuery.setMaxWordLen(jp.getIntValue());
|
||||||
} else if ("boost_terms".equals(currentFieldName)) {
|
} else if ("boost_terms".equals(currentFieldName) || "boostTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setBoostTerms(true);
|
mltQuery.setBoostTerms(true);
|
||||||
mltQuery.setBoostTermsFactor(jp.getIntValue());
|
mltQuery.setBoostTermsFactor(jp.getIntValue());
|
||||||
} else if ("percent_terms_to_match".equals(currentFieldName)) {
|
} else if ("percent_terms_to_match".equals(currentFieldName) || "percentTermsToMatch".equals(currentFieldName)) {
|
||||||
mltQuery.setPercentTermsToMatch(jp.getIntValue());
|
mltQuery.setPercentTermsToMatch(jp.getIntValue());
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
mltQuery.setBoost(jp.getIntValue());
|
mltQuery.setBoost(jp.getIntValue());
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
||||||
if ("boost_terms".equals(currentFieldName)) {
|
if ("boost_terms".equals(currentFieldName) || "boostTerms".equals(currentFieldName)) {
|
||||||
mltQuery.setBoostTerms(true);
|
mltQuery.setBoostTerms(true);
|
||||||
mltQuery.setBoostTermsFactor(jp.getFloatValue());
|
mltQuery.setBoostTermsFactor(jp.getFloatValue());
|
||||||
} else if ("percent_terms_to_match".equals(currentFieldName)) {
|
} else if ("percent_terms_to_match".equals(currentFieldName) || "percentTermsToMatch".equals(currentFieldName)) {
|
||||||
mltQuery.setPercentTermsToMatch(jp.getFloatValue());
|
mltQuery.setPercentTermsToMatch(jp.getFloatValue());
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
mltQuery.setBoost(jp.getFloatValue());
|
mltQuery.setBoost(jp.getFloatValue());
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.START_ARRAY) {
|
} else if (token == JsonToken.START_ARRAY) {
|
||||||
if ("stop_words".equals(currentFieldName)) {
|
if ("stop_words".equals(currentFieldName) || "stopWords".equals(currentFieldName)) {
|
||||||
Set<String> stopWords = Sets.newHashSet();
|
Set<String> stopWords = Sets.newHashSet();
|
||||||
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
while ((token = jp.nextToken()) != JsonToken.END_ARRAY) {
|
||||||
stopWords.add(jp.getText());
|
stopWords.add(jp.getText());
|
||||||
|
|
|
@ -37,6 +37,7 @@ import org.elasticsearch.index.query.support.MapperQueryParser;
|
||||||
import org.elasticsearch.index.query.support.MultiFieldMapperQueryParser;
|
import org.elasticsearch.index.query.support.MultiFieldMapperQueryParser;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
import org.elasticsearch.util.Booleans;
|
import org.elasticsearch.util.Booleans;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
import org.elasticsearch.util.trove.ExtTObjectFloatHashMap;
|
import org.elasticsearch.util.trove.ExtTObjectFloatHashMap;
|
||||||
|
|
||||||
|
@ -60,7 +61,7 @@ public class QueryStringJsonQueryParser extends AbstractIndexComponent implement
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME};
|
return new String[]{NAME, Strings.toCamelCase(NAME)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
@ -123,9 +124,9 @@ public class QueryStringJsonQueryParser extends AbstractIndexComponent implement
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("query".equals(currentFieldName)) {
|
if ("query".equals(currentFieldName)) {
|
||||||
queryString = jp.getText();
|
queryString = jp.getText();
|
||||||
} else if ("default_field".equals(currentFieldName)) {
|
} else if ("default_field".equals(currentFieldName) || "defaultField".equals(currentFieldName)) {
|
||||||
defaultField = parseContext.indexName(jp.getText());
|
defaultField = parseContext.indexName(jp.getText());
|
||||||
} else if ("default_operator".equals(currentFieldName)) {
|
} else if ("default_operator".equals(currentFieldName) || "defaultOperator".equals(currentFieldName)) {
|
||||||
String op = jp.getText();
|
String op = jp.getText();
|
||||||
if ("or".equalsIgnoreCase(op)) {
|
if ("or".equalsIgnoreCase(op)) {
|
||||||
defaultOperator = QueryParser.Operator.OR;
|
defaultOperator = QueryParser.Operator.OR;
|
||||||
|
@ -136,67 +137,67 @@ public class QueryStringJsonQueryParser extends AbstractIndexComponent implement
|
||||||
}
|
}
|
||||||
} else if ("analyzer".equals(currentFieldName)) {
|
} else if ("analyzer".equals(currentFieldName)) {
|
||||||
analyzer = analysisService.analyzer(jp.getText());
|
analyzer = analysisService.analyzer(jp.getText());
|
||||||
} else if ("allow_leading_wildcard".equals(currentFieldName)) {
|
} else if ("allow_leading_wildcard".equals(currentFieldName) || "allowLeadingWildcard".equals(currentFieldName)) {
|
||||||
allowLeadingWildcard = Booleans.parseBoolean(jp.getText(), false);
|
allowLeadingWildcard = Booleans.parseBoolean(jp.getText(), false);
|
||||||
} else if ("lowercase_expanded_terms".equals(currentFieldName)) {
|
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||||
lowercaseExpandedTerms = Booleans.parseBoolean(jp.getText(), false);
|
lowercaseExpandedTerms = Booleans.parseBoolean(jp.getText(), false);
|
||||||
} else if ("enable_position_increments".equals(currentFieldName)) {
|
} else if ("enable_position_increments".equals(currentFieldName) || "enablePositionIncrements".equals(currentFieldName)) {
|
||||||
enablePositionIncrements = Booleans.parseBoolean(jp.getText(), false);
|
enablePositionIncrements = Booleans.parseBoolean(jp.getText(), false);
|
||||||
} else if ("escape".equals(currentFieldName)) {
|
} else if ("escape".equals(currentFieldName)) {
|
||||||
escape = Booleans.parseBoolean(jp.getText(), false);
|
escape = Booleans.parseBoolean(jp.getText(), false);
|
||||||
} else if ("use_dis_max".equals(currentFieldName)) {
|
} else if ("use_dis_max".equals(currentFieldName) || "useDisMax".equals(currentFieldName)) {
|
||||||
useDisMax = Booleans.parseBoolean(jp.getText(), false);
|
useDisMax = Booleans.parseBoolean(jp.getText(), false);
|
||||||
} else if ("fuzzy_prefix_length".equals(currentFieldName)) {
|
} else if ("fuzzy_prefix_length".equals(currentFieldName) || "fuzzyPrefixLength".equals(currentFieldName)) {
|
||||||
fuzzyPrefixLength = Integer.parseInt(jp.getText());
|
fuzzyPrefixLength = Integer.parseInt(jp.getText());
|
||||||
} else if ("phrase_slop".equals(currentFieldName)) {
|
} else if ("phrase_slop".equals(currentFieldName) || "phraseSlop".equals(currentFieldName)) {
|
||||||
phraseSlop = Integer.parseInt(jp.getText());
|
phraseSlop = Integer.parseInt(jp.getText());
|
||||||
} else if ("fuzzy_min_sim".equals(currentFieldName)) {
|
} else if ("fuzzy_min_sim".equals(currentFieldName) || "fuzzyMinSim".equals(currentFieldName)) {
|
||||||
fuzzyMinSim = Float.parseFloat(jp.getText());
|
fuzzyMinSim = Float.parseFloat(jp.getText());
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = Float.parseFloat(jp.getText());
|
boost = Float.parseFloat(jp.getText());
|
||||||
} else if ("tie_breaker".equals(currentFieldName)) {
|
} else if ("tie_breaker".equals(currentFieldName) || "tieBreaker".equals(currentFieldName)) {
|
||||||
tieBreaker = Float.parseFloat(jp.getText());
|
tieBreaker = Float.parseFloat(jp.getText());
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE) {
|
} else if (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE) {
|
||||||
if ("allow_leading_wildcard".equals(currentFieldName)) {
|
if ("allow_leading_wildcard".equals(currentFieldName) || "allowLeadingWildcards".equals(currentFieldName)) {
|
||||||
allowLeadingWildcard = token == JsonToken.VALUE_TRUE;
|
allowLeadingWildcard = token == JsonToken.VALUE_TRUE;
|
||||||
} else if ("lowercase_expanded_terms".equals(currentFieldName)) {
|
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||||
lowercaseExpandedTerms = token == JsonToken.VALUE_TRUE;
|
lowercaseExpandedTerms = token == JsonToken.VALUE_TRUE;
|
||||||
} else if ("enable_position_increments".equals(currentFieldName)) {
|
} else if ("enable_position_increments".equals(currentFieldName) || "enablePositionIncrements".equals(currentFieldName)) {
|
||||||
enablePositionIncrements = token == JsonToken.VALUE_TRUE;
|
enablePositionIncrements = token == JsonToken.VALUE_TRUE;
|
||||||
} else if ("escape".equals(currentFieldName)) {
|
} else if ("escape".equals(currentFieldName)) {
|
||||||
escape = token == JsonToken.VALUE_TRUE;
|
escape = token == JsonToken.VALUE_TRUE;
|
||||||
} else if ("use_dis_max".equals(currentFieldName)) {
|
} else if ("use_dis_max".equals(currentFieldName) || "useDisMax".equals(currentFieldName)) {
|
||||||
useDisMax = token == JsonToken.VALUE_TRUE;
|
useDisMax = token == JsonToken.VALUE_TRUE;
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
} else if (token == JsonToken.VALUE_NUMBER_FLOAT) {
|
||||||
if ("fuzzy_min_sim".equals(currentFieldName)) {
|
if ("fuzzy_min_sim".equals(currentFieldName) || "fuzzyMinSim".equals(currentFieldName)) {
|
||||||
fuzzyMinSim = jp.getFloatValue();
|
fuzzyMinSim = jp.getFloatValue();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
} else if ("tie_breaker".equals(currentFieldName)) {
|
} else if ("tie_breaker".equals(currentFieldName) || "tieBreaker".equals(currentFieldName)) {
|
||||||
tieBreaker = jp.getFloatValue();
|
tieBreaker = jp.getFloatValue();
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
if ("fuzzy_prefix_length".equals(currentFieldName)) {
|
if ("fuzzy_prefix_length".equals(currentFieldName) || "fuzzyPrefixLength".equals(currentFieldName)) {
|
||||||
fuzzyPrefixLength = jp.getIntValue();
|
fuzzyPrefixLength = jp.getIntValue();
|
||||||
} else if ("phrase_slop".equals(currentFieldName)) {
|
} else if ("phrase_slop".equals(currentFieldName) || "phraseSlop".equals(currentFieldName)) {
|
||||||
phraseSlop = jp.getIntValue();
|
phraseSlop = jp.getIntValue();
|
||||||
} else if ("fuzzy_min_sim".equals(currentFieldName)) {
|
} else if ("fuzzy_min_sim".equals(currentFieldName) || "fuzzyMinSim".equals(currentFieldName)) {
|
||||||
fuzzyMinSim = jp.getFloatValue();
|
fuzzyMinSim = jp.getFloatValue();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
} else if ("allow_leading_wildcard".equals(currentFieldName)) {
|
} else if ("allow_leading_wildcard".equals(currentFieldName) || "allowLeadingWildcard".equals(currentFieldName)) {
|
||||||
allowLeadingWildcard = jp.getIntValue() != 0;
|
allowLeadingWildcard = jp.getIntValue() != 0;
|
||||||
} else if ("lowercase_expanded_terms".equals(currentFieldName)) {
|
} else if ("lowercase_expanded_terms".equals(currentFieldName) || "lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||||
lowercaseExpandedTerms = jp.getIntValue() != 0;
|
lowercaseExpandedTerms = jp.getIntValue() != 0;
|
||||||
} else if ("enable_position_increments".equals(currentFieldName)) {
|
} else if ("enable_position_increments".equals(currentFieldName) || "enablePositionIncrements".equals(currentFieldName)) {
|
||||||
enablePositionIncrements = jp.getIntValue() != 0;
|
enablePositionIncrements = jp.getIntValue() != 0;
|
||||||
} else if ("escape".equals(currentFieldName)) {
|
} else if ("escape".equals(currentFieldName)) {
|
||||||
escape = jp.getIntValue() != 0;
|
escape = jp.getIntValue() != 0;
|
||||||
} else if ("use_dis_max".equals(currentFieldName)) {
|
} else if ("use_dis_max".equals(currentFieldName) || "useDisMax".equals(currentFieldName)) {
|
||||||
useDisMax = jp.getIntValue() != 0;
|
useDisMax = jp.getIntValue() != 0;
|
||||||
} else if ("tie_breaker".equals(currentFieldName)) {
|
} else if ("tie_breaker".equals(currentFieldName) || "tieBreaker".equals(currentFieldName)) {
|
||||||
tieBreaker = jp.getFloatValue();
|
tieBreaker = jp.getFloatValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,7 @@ public class RangeJsonFilterParser extends AbstractIndexComponent implements Jso
|
||||||
} else {
|
} else {
|
||||||
to = jp.getText();
|
to = jp.getText();
|
||||||
}
|
}
|
||||||
} else if ("include_lower".equals(currentFieldName)) {
|
} else if ("include_lower".equals(currentFieldName) || "includeLower".equals(currentFieldName)) {
|
||||||
if (token == JsonToken.VALUE_NUMBER_INT) {
|
if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
includeLower = jp.getIntValue() != 0;
|
includeLower = jp.getIntValue() != 0;
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
|
@ -92,7 +92,7 @@ public class RangeJsonFilterParser extends AbstractIndexComponent implements Jso
|
||||||
} else {
|
} else {
|
||||||
includeLower = token == JsonToken.VALUE_TRUE;
|
includeLower = token == JsonToken.VALUE_TRUE;
|
||||||
}
|
}
|
||||||
} else if ("include_upper".equals(currentFieldName)) {
|
} else if ("include_upper".equals(currentFieldName) || "includeUpper".equals(currentFieldName)) {
|
||||||
if (token == JsonToken.VALUE_NUMBER_INT) {
|
if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
includeUpper = jp.getIntValue() != 0;
|
includeUpper = jp.getIntValue() != 0;
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
|
@ -107,7 +107,7 @@ public class RangeJsonFilterParser extends AbstractIndexComponent implements Jso
|
||||||
from = jp.getText();
|
from = jp.getText();
|
||||||
}
|
}
|
||||||
includeLower = false;
|
includeLower = false;
|
||||||
} else if ("gte".equals(currentFieldName)) {
|
} else if ("gte".equals(currentFieldName) || "ge".equals(currentFieldName)) {
|
||||||
if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
|
if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
|
||||||
from = null;
|
from = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -121,7 +121,7 @@ public class RangeJsonFilterParser extends AbstractIndexComponent implements Jso
|
||||||
to = jp.getText();
|
to = jp.getText();
|
||||||
}
|
}
|
||||||
includeUpper = false;
|
includeUpper = false;
|
||||||
} else if ("lte".equals(currentFieldName)) {
|
} else if ("lte".equals(currentFieldName) || "le".equals(currentFieldName)) {
|
||||||
if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
|
if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
|
||||||
to = null;
|
to = null;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class RangeJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
} else {
|
} else {
|
||||||
to = jp.getText();
|
to = jp.getText();
|
||||||
}
|
}
|
||||||
} else if ("include_lower".equals(currentFieldName)) {
|
} else if ("include_lower".equals(currentFieldName) || "includeLower".equals(currentFieldName)) {
|
||||||
if (token == JsonToken.VALUE_NUMBER_INT) {
|
if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
includeLower = jp.getIntValue() != 0;
|
includeLower = jp.getIntValue() != 0;
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
|
@ -89,7 +89,7 @@ public class RangeJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
} else {
|
} else {
|
||||||
includeLower = token == JsonToken.VALUE_TRUE;
|
includeLower = token == JsonToken.VALUE_TRUE;
|
||||||
}
|
}
|
||||||
} else if ("include_upper".equals(currentFieldName)) {
|
} else if ("include_upper".equals(currentFieldName) || "includeUpper".equals(currentFieldName)) {
|
||||||
if (token == JsonToken.VALUE_NUMBER_INT) {
|
if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
includeUpper = jp.getIntValue() != 0;
|
includeUpper = jp.getIntValue() != 0;
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
|
@ -110,7 +110,7 @@ public class RangeJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
from = jp.getText();
|
from = jp.getText();
|
||||||
}
|
}
|
||||||
includeLower = false;
|
includeLower = false;
|
||||||
} else if ("gte".equals(currentFieldName)) {
|
} else if ("gte".equals(currentFieldName) || "ge".equals(currentFieldName)) {
|
||||||
if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
|
if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
|
||||||
from = null;
|
from = null;
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,7 +124,7 @@ public class RangeJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
to = jp.getText();
|
to = jp.getText();
|
||||||
}
|
}
|
||||||
includeUpper = false;
|
includeUpper = false;
|
||||||
} else if ("lte".equals(currentFieldName)) {
|
} else if ("lte".equals(currentFieldName) || "le".equals(currentFieldName)) {
|
||||||
if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
|
if (jp.getCurrentToken() == JsonToken.VALUE_NULL) {
|
||||||
to = null;
|
to = null;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -45,7 +46,7 @@ public class SpanFirstJsonQueryParser extends AbstractIndexComponent implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME};
|
return new String[]{NAME, Strings.toCamelCase(NAME)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
import org.elasticsearch.util.Booleans;
|
import org.elasticsearch.util.Booleans;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -49,7 +50,7 @@ public class SpanNearJsonQueryParser extends AbstractIndexComponent implements J
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME};
|
return new String[]{NAME, Strings.toCamelCase(NAME)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
@ -78,9 +79,9 @@ public class SpanNearJsonQueryParser extends AbstractIndexComponent implements J
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_STRING) {
|
} else if (token == JsonToken.VALUE_STRING) {
|
||||||
if ("in_order".equals(currentFieldName)) {
|
if ("in_order".equals(currentFieldName) || "inOrder".equals(currentFieldName)) {
|
||||||
inOrder = Booleans.parseBoolean(jp.getText(), inOrder);
|
inOrder = Booleans.parseBoolean(jp.getText(), inOrder);
|
||||||
} else if ("collect_payloads".equals(currentFieldName)) {
|
} else if ("collect_payloads".equals(currentFieldName) || "collectPayloads".equals(currentFieldName)) {
|
||||||
collectPayloads = Booleans.parseBoolean(jp.getText(), collectPayloads);
|
collectPayloads = Booleans.parseBoolean(jp.getText(), collectPayloads);
|
||||||
} else if ("slop".equals(currentFieldName)) {
|
} else if ("slop".equals(currentFieldName)) {
|
||||||
slop = Integer.parseInt(jp.getText());
|
slop = Integer.parseInt(jp.getText());
|
||||||
|
@ -88,15 +89,15 @@ public class SpanNearJsonQueryParser extends AbstractIndexComponent implements J
|
||||||
boost = Float.parseFloat(jp.getText());
|
boost = Float.parseFloat(jp.getText());
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE) {
|
} else if (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE) {
|
||||||
if ("in_order".equals(currentFieldName)) {
|
if ("in_order".equals(currentFieldName) || "inOrder".equals(currentFieldName)) {
|
||||||
inOrder = token == JsonToken.VALUE_TRUE;
|
inOrder = token == JsonToken.VALUE_TRUE;
|
||||||
} else if ("collect_payloads".equals(currentFieldName)) {
|
} else if ("collect_payloads".equals(currentFieldName) || "collectPayloads".equals(currentFieldName)) {
|
||||||
collectPayloads = token == JsonToken.VALUE_TRUE;
|
collectPayloads = token == JsonToken.VALUE_TRUE;
|
||||||
}
|
}
|
||||||
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
if ("in_order".equals(currentFieldName)) {
|
if ("in_order".equals(currentFieldName) || "inOrder".equals(currentFieldName)) {
|
||||||
inOrder = jp.getIntValue() != 0;
|
inOrder = jp.getIntValue() != 0;
|
||||||
} else if ("collect_payloads".equals(currentFieldName)) {
|
} else if ("collect_payloads".equals(currentFieldName) || "collectPayloads".equals(currentFieldName)) {
|
||||||
collectPayloads = jp.getIntValue() != 0;
|
collectPayloads = jp.getIntValue() != 0;
|
||||||
} else if ("slop".equals(currentFieldName)) {
|
} else if ("slop".equals(currentFieldName)) {
|
||||||
slop = jp.getIntValue();
|
slop = jp.getIntValue();
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -45,7 +46,7 @@ public class SpanNotJsonQueryParser extends AbstractIndexComponent implements Js
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME};
|
return new String[]{NAME, Strings.toCamelCase(NAME)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
|
|
@ -29,6 +29,7 @@ import org.elasticsearch.index.AbstractIndexComponent;
|
||||||
import org.elasticsearch.index.Index;
|
import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -48,7 +49,7 @@ public class SpanOrJsonQueryParser extends AbstractIndexComponent implements Jso
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME};
|
return new String[]{NAME, Strings.toCamelCase(NAME)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
|
|
@ -30,6 +30,7 @@ import org.elasticsearch.index.Index;
|
||||||
import org.elasticsearch.index.mapper.MapperService;
|
import org.elasticsearch.index.mapper.MapperService;
|
||||||
import org.elasticsearch.index.query.QueryParsingException;
|
import org.elasticsearch.index.query.QueryParsingException;
|
||||||
import org.elasticsearch.index.settings.IndexSettings;
|
import org.elasticsearch.index.settings.IndexSettings;
|
||||||
|
import org.elasticsearch.util.Strings;
|
||||||
import org.elasticsearch.util.settings.Settings;
|
import org.elasticsearch.util.settings.Settings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -48,7 +49,7 @@ public class SpanTermJsonQueryParser extends AbstractIndexComponent implements J
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public String[] names() {
|
@Override public String[] names() {
|
||||||
return new String[]{NAME};
|
return new String[]{NAME, Strings.toCamelCase(NAME)};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
@Override public Query parse(JsonQueryParseContext parseContext) throws IOException, QueryParsingException {
|
||||||
|
|
Loading…
Reference in New Issue