Streamline single value with boost queries: Allow for both value and query name to specify the query value, closes #192.

This commit is contained in:
kimchy 2010-05-28 12:23:51 +03:00
parent 493464ba02
commit 3406e77cec
4 changed files with 11 additions and 3 deletions

View File

@ -68,7 +68,9 @@ public class PrefixQueryParser extends AbstractIndexComponent implements XConten
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else if (token.isValue()) { } else if (token.isValue()) {
if (NAME.equals(currentFieldName)) { if ("prefix".equals(currentFieldName)) {
value = parser.text();
} else if ("value".equals(currentFieldName)) {
value = parser.text(); value = parser.text();
} else if ("boost".equals(currentFieldName)) { } else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue(); boost = parser.floatValue();

View File

@ -71,7 +71,9 @@ public class SpanTermQueryParser extends AbstractIndexComponent implements XCont
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else { } else {
if ("value".equals(currentFieldName)) { if ("term".equals(currentFieldName)) {
value = parser.text();
} else if ("value".equals(currentFieldName)) {
value = parser.text(); value = parser.text();
} else if ("boost".equals(currentFieldName)) { } else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue(); boost = parser.floatValue();

View File

@ -66,7 +66,9 @@ public class TermQueryParser extends AbstractIndexComponent implements XContentQ
if (token == XContentParser.Token.FIELD_NAME) { if (token == XContentParser.Token.FIELD_NAME) {
currentFieldName = parser.currentName(); currentFieldName = parser.currentName();
} else { } else {
if ("value".equals(currentFieldName)) { if ("term".equals(currentFieldName)) {
value = parser.text();
} else if ("value".equals(currentFieldName)) {
value = parser.text(); value = parser.text();
} else if ("boost".equals(currentFieldName)) { } else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue(); boost = parser.floatValue();

View File

@ -70,6 +70,8 @@ public class WildcardQueryParser extends AbstractIndexComponent implements XCont
} else { } else {
if ("wildcard".equals(currentFieldName)) { if ("wildcard".equals(currentFieldName)) {
value = parser.text(); value = parser.text();
} else if ("value".equals(currentFieldName)) {
value = parser.text();
} else if ("boost".equals(currentFieldName)) { } else if ("boost".equals(currentFieldName)) {
boost = parser.floatValue(); boost = parser.floatValue();
} }