termsFilter (java API)

What's the correct way to use termsFilter from the Java API?

The method is defined as termsFilter(String name, int... values). This
is fine if you have some fixed number of values to pass in that you
can explicitly enumerate in code, but I have a variably sized list.

I tried passing ArrayList as the parameter. Java accepts this
syntactically, but it doesn't work:

Caused by: java.io.IOException: Type not allowed [class
java.util.ArrayList]
at
org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.java:
747)
at
org.elasticsearch.index.query.TermsFilterBuilder.doXContent(TermsFilterBuilder.java:
144)
at
org.elasticsearch.index.query.BaseFilterBuilder.toXContent(BaseFilterBuilder.java:
33)
at
org.elasticsearch.index.query.AndFilterBuilder.doXContent(AndFilterBuilder.java:
81)
at
org.elasticsearch.index.query.BaseFilterBuilder.toXContent(BaseFilterBuilder.java:
33)
at
org.elasticsearch.search.builder.SearchSourceBuilder.toXContent(SearchSourceBuilder.java:
548)
at
org.elasticsearch.search.builder.SearchSourceBuilder.buildAsBytesStream(SearchSourceBuilder.java:
501)
... 8 more

did you try to convert it into an array? which version do you use? I
think it has fixed in a recent version...

Peter.

On 17 Jan., 22:58, Frank LaRosa fr...@studyblue.com wrote:

What's the correct way to use termsFilter from the Java API?

The method is defined as termsFilter(String name, int... values). This
is fine if you have some fixed number of values to pass in that you
can explicitly enumerate in code, but I have a variably sized list.

I tried passing ArrayList as the parameter. Java accepts this
syntactically, but it doesn't work:

Caused by: java.io.IOException: Type not allowed [class
java.util.ArrayList]
at
org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.jav a:
747)
at
org.elasticsearch.index.query.TermsFilterBuilder.doXContent(TermsFilterBuil der.java:
144)
at
org.elasticsearch.index.query.BaseFilterBuilder.toXContent(BaseFilterBuilde r.java:
33)
at
org.elasticsearch.index.query.AndFilterBuilder.doXContent(AndFilterBuilder. java:
81)
at
org.elasticsearch.index.query.BaseFilterBuilder.toXContent(BaseFilterBuilde r.java:
33)
at
org.elasticsearch.search.builder.SearchSourceBuilder.toXContent(SearchSourc eBuilder.java:
548)
at
org.elasticsearch.search.builder.SearchSourceBuilder.buildAsBytesStream(Sea rchSourceBuilder.java:
501)
... 8 more

I pushed support for TermsFilterBuilder to support Iterable as well. Will
be in 0.19.

On Wed, Jan 18, 2012 at 10:56 AM, Karussell tableyourtime@googlemail.comwrote:

did you try to convert it into an array? which version do you use? I
think it has fixed in a recent version...

Peter.

On 17 Jan., 22:58, Frank LaRosa fr...@studyblue.com wrote:

What's the correct way to use termsFilter from the Java API?

The method is defined as termsFilter(String name, int... values). This
is fine if you have some fixed number of values to pass in that you
can explicitly enumerate in code, but I have a variably sized list.

I tried passing ArrayList as the parameter. Java accepts this
syntactically, but it doesn't work:

Caused by: java.io.IOException: Type not allowed [class
java.util.ArrayList]
at

org.elasticsearch.common.xcontent.XContentBuilder.value(XContentBuilder.jav
a:

  1. at

org.elasticsearch.index.query.TermsFilterBuilder.doXContent(TermsFilterBuil
der.java:

  1. at

org.elasticsearch.index.query.BaseFilterBuilder.toXContent(BaseFilterBuilde
r.java:

  1. at
    

org.elasticsearch.index.query.AndFilterBuilder.doXContent(AndFilterBuilder.
java:

  1. at
    

org.elasticsearch.index.query.BaseFilterBuilder.toXContent(BaseFilterBuilde
r.java:

  1. at
    

org.elasticsearch.search.builder.SearchSourceBuilder.toXContent(SearchSourc
eBuilder.java:

  1. at

org.elasticsearch.search.builder.SearchSourceBuilder.buildAsBytesStream(Sea
rchSourceBuilder.java:

  1. ... 8 more