Searching multiple types using Groovy client


(Manish) #1

I appreciate if someone can let me know how do I pass the types names
using groovy client if I want my search to include many types . I've
tried to pass , (comma) separated names in variable "searchTypes" in
the code below but it didn't seem to work.
def res = getClient().search {
indices searchIndices
types searchTypes
source searchSource
}

Thanks in advance....
Manish


(Shay Banon) #2

The closure you pass gets evaluated into a SearchRequest object, which has a
method called: types(String... types). Note, you can always use the "static"
type APIs.

On Thu, Sep 1, 2011 at 7:25 PM, Manish singhmanishp@gmail.com wrote:

I appreciate if someone can let me know how do I pass the types names
using groovy client if I want my search to include many types . I've
tried to pass , (comma) separated names in variable "searchTypes" in
the code below but it didn't seem to work.
def res = getClient().search {
indices searchIndices
types searchTypes
source searchSource
}

Thanks in advance....
Manish


(Manish) #3

Hi Shay,

Thanks! I got the idea how types(String... types) should be used. In
my code these types are dynamic. I need to sometimes pass a single
type and sometimes many types so I cannot use types(String... types)
as it forces me to hardcode the types (Probably a method signature
like types(String [] types) suits better for dynamically changing the
types.. similar to indices method). Could you elaborate more on use of
the "static" type APIs you mentioned or point me to some documentation
on it. May be I find some solution there...

Best regards,
Manish

On Sep 1, 9:05 pm, Shay Banon kim...@gmail.com wrote:

The closure you pass gets evaluated into a SearchRequest object, which has a
method called: types(String... types). Note, you can always use the "static"
type APIs.

On Thu, Sep 1, 2011 at 7:25 PM, Manish singhmani...@gmail.com wrote:

I appreciate if someone can let me know how do I pass the types names
using groovy client if I want my search to include many types . I've
tried to pass , (comma) separated names in variable "searchTypes" in
the code below but it didn't seem to work.
def res = getClient().search {
indices searchIndices
types searchTypes
source searchSource
}

Thanks in advance....
Manish


(Manish) #4

It would be great if someone can elaborate what is meant by " "static"
type APIs." in this mail thread. I am new to the ElasticSearch
world... not able to find the meaning / documentation on it.

Thanks
Manish

On Sep 2, 12:55 pm, Manish singhmani...@gmail.com wrote:

Hi Shay,

Thanks! I got the idea howtypes(String...types) should be used. In
my code thesetypesare dynamic. I need to sometimes pass a single
type and sometimes manytypesso I cannot usetypes(String...types)
as it forces me to hardcode thetypes(Probably a method signature
liketypes(String []types) suits better for dynamically changing thetypes.. similar to indices method). Could you elaborate more on use of
the "static" type APIs you mentioned or point me to some documentation
on it. May be I find some solution there...

Best regards,
Manish

On Sep 1, 9:05 pm, Shay Banon kim...@gmail.com wrote:

The closure you pass gets evaluated into a SearchRequest object, which has a
method called:types(String...types). Note, you can always use the "static"
type APIs.

On Thu, Sep 1, 2011 at 7:25 PM, Manish singhmani...@gmail.com wrote:

I appreciate if someone can let me know how do I pass thetypesnames
usinggroovyclientif I want my search to include manytypes. I've
tried to pass , (comma) separated names in variable "searchTypes" in
the code below but it didn't seem to work.
def res = getClient().search {
indices searchIndices
typessearchTypes
source searchSource
}

Thanks in advance....
Manish


(Shay Banon) #5

Not sure I understand, if its a single value, why can't you call types? The
"static" method calls are just hte plain Java API calls, check the
prepareXXX method on the groovy client (which are the same in the wrapped
Java client).

On Fri, Sep 2, 2011 at 12:55 PM, Manish singhmanishp@gmail.com wrote:

Hi Shay,

Thanks! I got the idea how types(String... types) should be used. In
my code these types are dynamic. I need to sometimes pass a single
type and sometimes many types so I cannot use types(String... types)
as it forces me to hardcode the types (Probably a method signature
like types(String [] types) suits better for dynamically changing the
types.. similar to indices method). Could you elaborate more on use of
the "static" type APIs you mentioned or point me to some documentation
on it. May be I find some solution there...

Best regards,
Manish

On Sep 1, 9:05 pm, Shay Banon kim...@gmail.com wrote:

The closure you pass gets evaluated into a SearchRequest object, which
has a
method called: types(String... types). Note, you can always use the
"static"
type APIs.

On Thu, Sep 1, 2011 at 7:25 PM, Manish singhmani...@gmail.com wrote:

I appreciate if someone can let me know how do I pass the types names
using groovy client if I want my search to include many types . I've
tried to pass , (comma) separated names in variable "searchTypes" in
the code below but it didn't seem to work.
def res = getClient().search {
indices searchIndices
types searchTypes
source searchSource
}

Thanks in advance....
Manish


(system) #6