# Does Groovy client support 'explain', and 'from / size'?

**URL:** <https://discuss.elastic.co/t/does-groovy-client-support-explain-and-from-size/3701>\
**Category:** Elasticsearch\
**Created:** [December 27, 2010, 5:35am UTC](https://discuss.elastic.co/t/does-groovy-client-support-explain-and-from-size/3701 "2010-12-27T05:35:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbro](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mbro](https://discuss.elastic.co/u/mbro)\
**Post date:** [December 27, 2010, 5:35am UTC](https://discuss.elastic.co/t/does-groovy-client-support-explain-and-from-size/3701/1 "2010-12-27T05:35:01Z")

</div>

Hi,

I can't get the Groovy client to accept the 'explain' or 'from / size'  
parameters. I get an error:

java.lang.IllegalArgumentException: Array elements must be defined  
with the "element" method call eg: element(value)  
at  
org.elasticsearch.groovy.common.xcontent.GXContentBuilder.invokeMethod(GXContentBuilder.groovy:  
122)  
.  
.  
.

Here is my Groovy code (running under Grails):

def search = esClient.search {  
indices "things"  
types "things"  
source {  
explain "true"  
query {  
query\_string (  
query : "this AND that"  
)  
}  
}  
}

I tried many variations (before 'source', without quotes around true,  
etc.) but can't get it to work.

Regards,  
Mike

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [December 27, 2010, 6:07am UTC](https://discuss.elastic.co/t/does-groovy-client-support-explain-and-from-size/3701/2 "2010-12-27T06:07:34Z")

</div>

Yea, it does. The logic for the builder is taken from grails JSONBuilder:  
[https://github.com/grails/grails-core/blob/master/src/java/grails/web/JSONBuilder.groovy](https://github.com/grails/grails-core/blob/master/src/java/grails/web/JSONBuilder.groovy).  
To be honest, I am not a groovy expert to tell you why sometimes you need to  
add `=` signs and sometimes you don't (or really, have not looked too deeply  
into it), but, it seems like, in this case, you do. So, here is how it would  
work:

def search = esClient.search {  
indices "things"  
types "things"  
source {  
explain = true  
query {  
query\_string (  
query : "this AND that"  
)  
}  
}

On Mon, Dec 27, 2010 at 7:35 AM, mbro [mike.brocious@gmail.com](mailto:mike.brocious@gmail.com) wrote:

> Hi,
> 
> I can't get the Groovy client to accept the 'explain' or 'from / size'  
> parameters. I get an error:
> 
> java.lang.IllegalArgumentException: Array elements must be defined  
> with the "element" method call eg: element(value)  
> at
> 
> org.elasticsearch.groovy.common.xcontent.GXContentBuilder.invokeMethod(GXContentBuilder.groovy:  
> 122)  
> .  
> .  
> .
> 
> Here is my Groovy code (running under Grails):
> 
> def search = esClient.search {  
> indices "things"  
> types "things"  
> source {  
> explain "true"  
> query {  
> query\_string (  
> query : "this AND that"  
> )  
> }  
> }  
> }
> 
> I tried many variations (before 'source', without quotes around true,  
> etc.) but can't get it to work.
> 
> Regards,  
> Mike

---

<div class="post-metadata">

**Author:** ![mbro](https://avatars.discourse-cdn.com/v4/letter/m/c37758/32.png) [@mbro](https://discuss.elastic.co/u/mbro)\
**Post date:** [December 27, 2010, 6:14pm UTC](https://discuss.elastic.co/t/does-groovy-client-support-explain-and-from-size/3701/3 "2010-12-27T18:14:13Z")

</div>

Thanks, Shay. That did the trick.

Wish I understood the Groovy syntax a little better myself...

On Mon, Dec 27, 2010 at 1:07 AM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> Yea, it does. The logic for the builder is taken from grails JSONBuilder:  
> [https://github.com/grails/grails-core/blob/master/src/java/grails/web/JSONBuilder.groovy](https://github.com/grails/grails-core/blob/master/src/java/grails/web/JSONBuilder.groovy).  
> To be honest, I am not a groovy expert to tell you why sometimes you need to  
> add `=` signs and sometimes you don't (or really, have not looked too deeply  
> into it), but, it seems like, in this case, you do. So, here is how it would  
> work:
> 
> def search = esClient.search {  
> indices "things"  
> types "things"  
> source {  
> explain = true  
> query {  
> query\_string (  
> query : "this AND that"  
> )  
> }  
> }
> 
> On Mon, Dec 27, 2010 at 7:35 AM, mbro [mike.brocious@gmail.com](mailto:mike.brocious@gmail.com) wrote:
> 
> > Hi,
> > 
> > I can't get the Groovy client to accept the 'explain' or 'from / size'  
> > parameters. I get an error:
> > 
> > java.lang.IllegalArgumentException: Array elements must be defined  
> > with the "element" method call eg: element(value)  
> > at
> > 
> > org.elasticsearch.groovy.common.xcontent.GXContentBuilder.invokeMethod(GXContentBuilder.groovy:  
> > 122)  
> > .  
> > .  
> > .
> > 
> > Here is my Groovy code (running under Grails):
> > 
> > def search = esClient.search {  
> > indices "things"  
> > types "things"  
> > source {  
> > explain "true"  
> > query {  
> > query\_string (  
> > query : "this AND that"  
> > )  
> > }  
> > }  
> > }
> > 
> > I tried many variations (before 'source', without quotes around true,  
> > etc.) but can't get it to work.
> > 
> > Regards,  
> > Mike

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 6, 2017, 4:14am UTC](https://discuss.elastic.co/t/does-groovy-client-support-explain-and-from-size/3701/4 "2017-07-06T04:14:47Z")

</div>

Closed on July 6, 2017, 4:14am UTC


