Skip to content

Commit f9cac39

Browse files
committed
Terms query is broken, closes #80.
1 parent fa55c40 commit f9cac39

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

modules/elasticsearch/src/main/java/org/elasticsearch/action/terms/TermsRequest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,11 @@ public String from() {
180180
* first.
181181
*/
182182
public TermsRequest from(Object from) {
183-
this.from = from.toString();
183+
if (from == null) {
184+
this.from = null;
185+
} else {
186+
this.from = from.toString();
187+
}
184188
return this;
185189
}
186190

@@ -202,17 +206,21 @@ public TermsRequest fromInclusive(boolean fromInclusive) {
202206
}
203207

204208
/**
205-
* The upper bound (lex) term to which the iteration will end. Defaults to unbound (<tt>null</tt>).
209+
* The upper bound term to which the iteration will end. Defaults to unbound (<tt>null</tt>).
206210
*/
207211
public String to() {
208212
return to;
209213
}
210214

211215
/**
212-
* The upper bound (lex) term to which the iteration will end. Defaults to unbound (<tt>null</tt>).
216+
* The upper bound term to which the iteration will end. Defaults to unbound (<tt>null</tt>).
213217
*/
214218
public TermsRequest to(Object to) {
215-
this.to = to.toString();
219+
if (to == null) {
220+
this.to = null;
221+
} else {
222+
this.to = to.toString();
223+
}
216224
return this;
217225
}
218226

modules/elasticsearch/src/main/java/org/elasticsearch/rest/action/terms/RestTermsAction.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,13 @@ public class RestTermsAction extends BaseRestHandler {
7272
termsRequest.operationThreading(operationThreading);
7373

7474
List<String> fields = request.params("field");
75-
if (fields == null) {
76-
fields = new ArrayList<String>();
77-
}
7875
String sField = request.param("fields");
7976
if (sField != null) {
8077
String[] sFields = fieldsPattern.split(sField);
8178
if (sFields != null) {
79+
if (fields == null) {
80+
fields = new ArrayList<String>();
81+
}
8282
for (String field : sFields) {
8383
fields.add(field);
8484
}

0 commit comments

Comments
 (0)