mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-03-25 01:19:02 +00:00
API Change: Terms - Add support for gt/gte/lt/lte, closes #108.
This commit is contained in:
parent
4e347425e8
commit
33086fb98d
@ -168,7 +168,7 @@ public class TermsRequest extends BroadcastOperationRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* The lower bound (lex) term from which the iteration will start. Defaults to start from the
|
||||
* The lower bound term from which the iteration will start. Defaults to start from the
|
||||
* first.
|
||||
*/
|
||||
public String from() {
|
||||
@ -176,7 +176,7 @@ public class TermsRequest extends BroadcastOperationRequest {
|
||||
}
|
||||
|
||||
/**
|
||||
* The lower bound (lex) term from which the iteration will start. Defaults to start from the
|
||||
* The lower bound term from which the iteration will start. Defaults to start from the
|
||||
* first.
|
||||
*/
|
||||
public TermsRequest from(Object from) {
|
||||
@ -188,6 +188,42 @@ public class TermsRequest extends BroadcastOperationRequest {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater than (like setting from with fromIInclusive set to <tt>false</tt>).
|
||||
*/
|
||||
public TermsRequest gt(Object from) {
|
||||
from(from);
|
||||
fromInclusive(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Greater/equal than (like setting from with fromInclusive set to <tt>true</tt>).
|
||||
*/
|
||||
public TermsRequest gte(Object from) {
|
||||
from(from);
|
||||
fromInclusive(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower then (like setting to with toInclusive set to <tt>false</tt>)
|
||||
*/
|
||||
public TermsRequest lt(Object to) {
|
||||
to(to);
|
||||
toInclusive(false);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lower/equal then (like setting to with toInclusive set to <tt>false</tt>)
|
||||
*/
|
||||
public TermsRequest lte(Object to) {
|
||||
to(to);
|
||||
toInclusive(true);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the first from (if set using {@link #from(Object)} be inclusive or not. Defaults
|
||||
* to <tt>false</tt> (not inclusive / exclusive).
|
||||
|
@ -90,6 +90,26 @@ public class RestTermsAction extends BaseRestHandler {
|
||||
termsRequest.to(request.param("to"));
|
||||
termsRequest.fromInclusive(request.paramAsBoolean("from_inclusive", termsRequest.fromInclusive()));
|
||||
termsRequest.toInclusive(request.paramAsBoolean("to_inclusive", termsRequest.toInclusive()));
|
||||
|
||||
Object temp = request.param("gt");
|
||||
if (temp != null) {
|
||||
termsRequest.gt(temp);
|
||||
} else {
|
||||
temp = request.param("gte");
|
||||
if (temp != null) {
|
||||
termsRequest.gte(temp);
|
||||
}
|
||||
}
|
||||
temp = request.param("lt");
|
||||
if (temp != null) {
|
||||
termsRequest.lt(temp);
|
||||
} else {
|
||||
temp = request.param("lte");
|
||||
if (temp != null) {
|
||||
termsRequest.lte(temp);
|
||||
}
|
||||
}
|
||||
|
||||
termsRequest.exact(request.paramAsBoolean("exact", termsRequest.exact()));
|
||||
termsRequest.minFreq(request.paramAsInt("min_freq", termsRequest.minFreq()));
|
||||
termsRequest.maxFreq(request.paramAsInt("max_freq", termsRequest.maxFreq()));
|
||||
|
Loading…
x
Reference in New Issue
Block a user