Skip to content

Commit

Permalink
Accept also 0 int number to indicate false, and any other number to i…
Browse files Browse the repository at this point in the history
…ndicate true (on top of accepting json boolean type), closes #26.
  • Loading branch information
kimchy committed Feb 20, 2010
1 parent 4806df4 commit 3f045de
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ public class BoolJsonQueryParser extends AbstractIndexComponent implements JsonQ
if ("disableCoord".equals(currentFieldName)) {
disableCoord = token == JsonToken.VALUE_TRUE;
}
} else if (token == JsonToken.VALUE_NUMBER_INT) {
if ("disableCoord".equals(currentFieldName)) {
disableCoord = jp.getIntValue() != 0;
}
} else {
if ("boost".equals(currentFieldName)) {
boost = jp.getFloatValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ public class QueryStringJsonQueryParser extends AbstractIndexComponent implement
fuzzyMinSim = jp.getFloatValue();
} else if ("boost".equals(currentFieldName)) {
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;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,17 @@ public class RangeJsonFilterParser extends AbstractIndexComponent implements Jso
to = jp.getText();
}
} 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)) {
includeUpper = token == JsonToken.VALUE_TRUE;
if (token == JsonToken.VALUE_NUMBER_INT) {
includeUpper = jp.getIntValue() != 0;
} else {
includeUpper = token == JsonToken.VALUE_TRUE;
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,17 @@ public class RangeJsonQueryParser extends AbstractIndexComponent implements Json
to = jp.getText();
}
} 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)) {
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)) {
boost = jp.getFloatValue();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,17 @@ public class SpanNearJsonQueryParser extends AbstractIndexComponent implements J
} else if ("collectPayloads".equals(currentFieldName)) {
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 {
if ("boost".equals(currentFieldName)) {
boost = jp.getFloatValue();
} else if ("slop".equals(currentFieldName)) {
slop = jp.getIntValue();
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@
public class ExplainParseElement implements SearchParseElement {

@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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ public SortParseElement() {
while ((token = jp.nextToken()) != JsonToken.END_OBJECT) {
if (token == JsonToken.FIELD_NAME) {
innerJsonName = jp.getCurrentName();
} else if (token == JsonToken.VALUE_NUMBER_INT) {
if ("reverse".equals(innerJsonName)) {
reverse = jp.getIntValue() != 0;
}
} else if (token == JsonToken.VALUE_TRUE) {
if ("reverse".equals(innerJsonName)) {
reverse = true;
Expand Down

0 comments on commit 3f045de

Please sign in to comment.