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

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

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.
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 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

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.comwrote:

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.
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 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