there are 2 methods:
public static TermsQueryBuilder termsQuery(String name, int... values) {
return new TermsQueryBuilder(name, values);
}
public static TermsQueryBuilder termsQuery(String name, Object... values) {
return new TermsQueryBuilder(name, values);
}
when i called
termsQuery("operatorType", 1);
it says that is ambiguous.
Please Help ...
all the methods are in Elasticsearch,for example:
public static TermsQueryBuilder termsQuery(String name, String... values) {
return new TermsQueryBuilder(name, values);
}
public static TermsQueryBuilder termsQuery(String name, int... values) {
return new TermsQueryBuilder(name, values);
}
public static TermsQueryBuilder termsQuery(String name, long... values) {
return new TermsQueryBuilder(name, values);
}
...
public static TermsQueryBuilder termsQuery(String name, Object... values) {
return new TermsQueryBuilder(name, values);
}
when I called termsQuery("operationType","1")
, not ambiguous.
when I called termsQuery("operationType",1)
, ambiguous.
when I called termsQuery("operationType",Arrays.asList(searchParam.getOperatorType())
, not ambiguous.
puzzled.....
Simply rename one or both of your methods and the error will go away.
You cannot overload this method with the signatures your desire, because your call can be matched by both method definitions, and the types int
and Object
are not in a superclass-subclass relationship, so neither is more specific than the other.
Consider
integerTermsQuery
and
objectTermsQuery
EDIT
As you point out in your comments, the version with the String...
parameter does not conflict with Object...
and arrays are covariant with String
being a subclass of Object
.