Query Syntax for arrays and nested objects

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Query Syntax for arrays and nested objects

eugeis
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"
            }
        ]
    }
}

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Query Syntax for arrays and nested objects

eugeis
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 <[hidden email]> 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"
>             }
>         ]
>     }
>
> }
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Query Syntax for arrays and nested objects

eugeis
Exists an "all" field like in compass?

Thank You

On 17 Feb., 09:02, eugeis <[hidden email]> 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 <[hidden email]> 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"
> >             }
> >         ]
> >     }
>
> > }
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Query Syntax for arrays and nested objects

kimchy
Administrator
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 <[hidden email]> wrote:
Exists an "all" field like in compass?

Thank You

On 17 Feb., 09:02, eugeis <[hidden email]> 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 <[hidden email]> 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"
> >             }
> >         ]
> >     }
>
> > }

Loading...