Accept also 0 int number to indicate false, and any other number to indicate true (on top of accepting json boolean type), closes #26.
This commit is contained in:
parent
4806df426a
commit
3f045dee1f
|
@ -89,6 +89,10 @@ public class BoolJsonQueryParser extends AbstractIndexComponent implements JsonQ
|
||||||
if ("disableCoord".equals(currentFieldName)) {
|
if ("disableCoord".equals(currentFieldName)) {
|
||||||
disableCoord = token == JsonToken.VALUE_TRUE;
|
disableCoord = token == JsonToken.VALUE_TRUE;
|
||||||
}
|
}
|
||||||
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
|
if ("disableCoord".equals(currentFieldName)) {
|
||||||
|
disableCoord = jp.getIntValue() != 0;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ("boost".equals(currentFieldName)) {
|
if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
|
|
|
@ -117,6 +117,12 @@ public class QueryStringJsonQueryParser extends AbstractIndexComponent implement
|
||||||
fuzzyMinSim = jp.getFloatValue();
|
fuzzyMinSim = jp.getFloatValue();
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
|
} else if ("allowLeadingWildcard".equals(currentFieldName)) {
|
||||||
|
allowLeadingWildcard = jp.getIntValue() != 0;
|
||||||
|
} else if ("lowercaseExpandedTerms".equals(currentFieldName)) {
|
||||||
|
lowercaseExpandedTerms = jp.getIntValue() != 0;
|
||||||
|
} else if ("enablePositionIncrements".equals(currentFieldName)) {
|
||||||
|
enablePositionIncrements = jp.getIntValue() != 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,9 +84,17 @@ public class RangeJsonFilterParser extends AbstractIndexComponent implements Jso
|
||||||
to = jp.getText();
|
to = jp.getText();
|
||||||
}
|
}
|
||||||
} else if ("includeLower".equals(currentFieldName)) {
|
} else if ("includeLower".equals(currentFieldName)) {
|
||||||
includeLower = token == JsonToken.VALUE_TRUE;
|
if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
|
includeLower = jp.getIntValue() != 0;
|
||||||
|
} else {
|
||||||
|
includeLower = token == JsonToken.VALUE_TRUE;
|
||||||
|
}
|
||||||
} else if ("includeUpper".equals(currentFieldName)) {
|
} else if ("includeUpper".equals(currentFieldName)) {
|
||||||
includeUpper = token == JsonToken.VALUE_TRUE;
|
if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
|
includeUpper = jp.getIntValue() != 0;
|
||||||
|
} else {
|
||||||
|
includeUpper = token == JsonToken.VALUE_TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -81,9 +81,17 @@ public class RangeJsonQueryParser extends AbstractIndexComponent implements Json
|
||||||
to = jp.getText();
|
to = jp.getText();
|
||||||
}
|
}
|
||||||
} else if ("includeLower".equals(currentFieldName)) {
|
} else if ("includeLower".equals(currentFieldName)) {
|
||||||
includeLower = token == JsonToken.VALUE_TRUE;
|
if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
|
includeLower = jp.getIntValue() != 0;
|
||||||
|
} else {
|
||||||
|
includeLower = token == JsonToken.VALUE_TRUE;
|
||||||
|
}
|
||||||
} else if ("includeUpper".equals(currentFieldName)) {
|
} else if ("includeUpper".equals(currentFieldName)) {
|
||||||
includeUpper = token == JsonToken.VALUE_TRUE;
|
if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
|
includeUpper = jp.getIntValue() != 0;
|
||||||
|
} else {
|
||||||
|
includeUpper = token == JsonToken.VALUE_TRUE;
|
||||||
|
}
|
||||||
} else if ("boost".equals(currentFieldName)) {
|
} else if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,11 +82,17 @@ public class SpanNearJsonQueryParser extends AbstractIndexComponent implements J
|
||||||
} else if ("collectPayloads".equals(currentFieldName)) {
|
} else if ("collectPayloads".equals(currentFieldName)) {
|
||||||
collectPayloads = token == JsonToken.VALUE_TRUE;
|
collectPayloads = token == JsonToken.VALUE_TRUE;
|
||||||
}
|
}
|
||||||
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
|
if ("inOrder".equals(currentFieldName)) {
|
||||||
|
inOrder = jp.getIntValue() != 0;
|
||||||
|
} else if ("collectPayloads".equals(currentFieldName)) {
|
||||||
|
collectPayloads = jp.getIntValue() != 0;
|
||||||
|
} else if ("slop".equals(currentFieldName)) {
|
||||||
|
slop = jp.getIntValue();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ("boost".equals(currentFieldName)) {
|
if ("boost".equals(currentFieldName)) {
|
||||||
boost = jp.getFloatValue();
|
boost = jp.getFloatValue();
|
||||||
} else if ("slop".equals(currentFieldName)) {
|
|
||||||
slop = jp.getIntValue();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@ import org.elasticsearch.search.internal.SearchContext;
|
||||||
public class ExplainParseElement implements SearchParseElement {
|
public class ExplainParseElement implements SearchParseElement {
|
||||||
|
|
||||||
@Override public void parse(JsonParser jp, SearchContext context) throws Exception {
|
@Override public void parse(JsonParser jp, SearchContext context) throws Exception {
|
||||||
context.explain(jp.getCurrentToken() == JsonToken.VALUE_TRUE);
|
if (jp.getCurrentToken() == JsonToken.VALUE_NUMBER_INT) {
|
||||||
|
context.explain(jp.getIntValue() != 0);
|
||||||
|
} else {
|
||||||
|
context.explain(jp.getCurrentToken() == JsonToken.VALUE_TRUE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,6 +68,10 @@ public class SortParseElement implements SearchParseElement {
|
||||||
while ((token = jp.nextToken()) != JsonToken.END_OBJECT) {
|
while ((token = jp.nextToken()) != JsonToken.END_OBJECT) {
|
||||||
if (token == JsonToken.FIELD_NAME) {
|
if (token == JsonToken.FIELD_NAME) {
|
||||||
innerJsonName = jp.getCurrentName();
|
innerJsonName = jp.getCurrentName();
|
||||||
|
} else if (token == JsonToken.VALUE_NUMBER_INT) {
|
||||||
|
if ("reverse".equals(innerJsonName)) {
|
||||||
|
reverse = jp.getIntValue() != 0;
|
||||||
|
}
|
||||||
} else if (token == JsonToken.VALUE_TRUE) {
|
} else if (token == JsonToken.VALUE_TRUE) {
|
||||||
if ("reverse".equals(innerJsonName)) {
|
if ("reverse".equals(innerJsonName)) {
|
||||||
reverse = true;
|
reverse = true;
|
||||||
|
|
Loading…
Reference in New Issue