Query Syntax for arrays and nested objects


(eugeis) #1

Hello,

how can Isearch in array type, e.g. I want to search by "name" field
of "lists" array

$ curl -XGET http://localhost:9200/_search?q=user.lists.name:prog*

{
tweet : {
message : "some arrays in this tweet...",
tags : ["elasticsearch", "wow"],
lists : [
{
name : "progList",
description : "programming list"
},
{
name : "coolList",
description : "cool stuff list"
}
]
}
}


(eugeis) #2

And same question for nested objects

e.g. $ curl -XGET http://localhost:9200/twitter/tweet/_search?q=person.name:Sh*

{
tweet {
person : {
name : {
firstName : "Shay",
lastName : "Banon"
},
sid : "12345"
},
message : "This is a tweet!"
}
}

On 17 Feb., 08:57, eugeis eoeis...@googlemail.com wrote:

Hello,

how can Isearch in array type, e.g. I want to search by "name" field
of "lists" array

$ curl -XGEThttp://localhost:9200/_search?q=user.lists.name:prog*

{
tweet : {
message : "some arrays in this tweet...",
tags : ["elasticsearch", "wow"],
lists : [
{
name : "progList",
description : "programming list"
},
{
name : "coolList",
description : "cool stuff list"
}
]
}

}


(eugeis) #3

Exists an "all" field like in compass?

Thank You

On 17 Feb., 09:02, eugeis eoeis...@googlemail.com wrote:

And same question for nested objects

e.g. $ curl -XGEThttp://localhost:9200/twitter/tweet/_search?q=person.name:Sh*

{
tweet {
person : {
name : {
firstName : "Shay",
lastName : "Banon"
},
sid : "12345"
},
message : "This is a tweet!"
}

}

On 17 Feb., 08:57, eugeis eoeis...@googlemail.com wrote:

Hello,

how can Isearch in array type, e.g. I want to search by "name" field
of "lists" array

$ curl -XGEThttp://localhost:9200/_search?q=user.lists.name:prog*

{
tweet : {
message : "some arrays in this tweet...",
tags : ["elasticsearch", "wow"],
lists : [
{
name : "progList",
description : "programming list"
},
{
name : "coolList",
description : "cool stuff list"
}
]
}

}


(Shay Banon) #4

There isn't an all field as in Compass, though there will be one in the
future (a bit more tricky to implement it with recent Lucene efficiently).

But, elasticsearch is agnostic to arrays (as in Compass), so you can have:
tweet.person.name.firstName:Shay, or person.name.firstName:Shay. With
arrays, you can have tweet.tags:wow (it will match on either values). I
explain it a bit more here:
http://www.elasticsearch.com/blog/2010/02/12/yourdatayoursearch.html.

-shay.banon

On Wed, Feb 17, 2010 at 10:03 AM, eugeis eoeisler@googlemail.com wrote:

Exists an "all" field like in compass?

Thank You

On 17 Feb., 09:02, eugeis eoeis...@googlemail.com wrote:

And same question for nested objects

e.g. $ curl
-XGEThttp://localhost:9200/twitter/tweet/_search?q=person.name:Sh*

{
tweet {
person : {
name : {
firstName : "Shay",
lastName : "Banon"
},
sid : "12345"
},
message : "This is a tweet!"
}

}

On 17 Feb., 08:57, eugeis eoeis...@googlemail.com wrote:

Hello,

how can Isearch in array type, e.g. I want to search by "name" field
of "lists" array

$ curl -XGEThttp://localhost:9200/_search?q=user.lists.name:prog*

{
tweet : {
message : "some arrays in this tweet...",
tags : ["elasticsearch", "wow"],
lists : [
{
name : "progList",
description : "programming list"
},
{
name : "coolList",
description : "cool stuff list"
}
]
}

}


(system) #5