Change the structure of response json

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Change the structure of response json

tfreitas
Hello Shay,

I have a years using compass, now I see elasticsearch, I want to play
with it.

With ElasticSearch I could do:
1) in  "search"  return a json structure different from the index?.

Example:
index:
{
    "User": "kimchy"
    "PostData": "2009-11-15T14: 12:12"
    "Message": "trying out Elastic Search"
}

and search:
{
    "_shards": {
        "Total": 5,
        "Successful": 5,
        "Failed": 0
    }
    "Hits": {
        "Total": 1,
        "Hits": [
            {
                "_index": "Twitter"
                "_type": "Tweet"
                "_id": "1"
                "_source": {
                    "User": "kimchy"
                    "Today": "2010-04-15T14: 12:12", / / calculated
dynamically, today's date
                    "Message": "trying out Elastic Search"
                    "Days": 180 / / calculated dynamically, the rest
of today-postData
                }
            }
        ]
    }
}

Moreover, in some cases might omit some control information, do not
send "_index", "_type", and "_id". This is possible?

2) I'm thinking that elasticsearch respond directly to requests from a
browser.
A website made  jsonp requests to search in elasticsearch, and respond
json for rendering in browser with PURE (http://beebole.com/pure/)
Think this solution is viable

Thanks, and sorry for my language mistakes
Reply | Threaded
Open this post in threaded view
|

Re: Change the structure of response json

kimchy
Administrator
Hi,

Regarding the first question, I am thinking of something very similar to enable in elasticsearch. Basically, allow to augment the results with more information. I have an idea on how to do this, but it will be at least 0.8 before I will try and tackle this. For now, you can front elasticsearch with your own server that augments the data.

cheers,
shay.banon

On Wed, Apr 21, 2010 at 5:41 AM, tfreitas <[hidden email]> wrote:
Hello Shay,

I have a years using compass, now I see elasticsearch, I want to play
with it.

With ElasticSearch I could do:
1) in  "search"  return a json structure different from the index?.

Example:
index:
{
   "User": "kimchy"
   "PostData": "2009-11-15T14: 12:12"
   "Message": "trying out Elastic Search"
}

and search:
{
   "_shards": {
       "Total": 5,
       "Successful": 5,
       "Failed": 0
   }
   "Hits": {
       "Total": 1,
       "Hits": [
           {
               "_index": "Twitter"
               "_type": "Tweet"
               "_id": "1"
               "_source": {
                   "User": "kimchy"
                   "Today": "2010-04-15T14: 12:12", / / calculated
dynamically, today's date
                   "Message": "trying out Elastic Search"
                   "Days": 180 / / calculated dynamically, the rest
of today-postData
               }
           }
       ]
   }
}

Moreover, in some cases might omit some control information, do not
send "_index", "_type", and "_id". This is possible?

2) I'm thinking that elasticsearch respond directly to requests from a
browser.
A website made  jsonp requests to search in elasticsearch, and respond
json for rendering in browser with PURE (http://beebole.com/pure/)
Think this solution is viable

Thanks, and sorry for my language mistakes

Reply | Threaded
Open this post in threaded view
|

Re: Change the structure of response json

tfreitas
What do you think about having "templates" response on the server?.
Could do this as a module in elasticsearch?

On Apr 21, 1:35 pm, Shay Banon <[hidden email]> wrote:

> Hi,
>
> Regarding the first question, I am thinking of something very similar to
> enable in elasticsearch. Basically, allow to augment the results with more
> information. I have an idea on how to do this, but it will be at least 0.8
> before I will try and tackle this. For now, you can front elasticsearch with
> your own server that augments the data.
>
> cheers,
> shay.banon
>
> On Wed, Apr 21, 2010 at 5:41 AM, tfreitas <[hidden email]> wrote:
> > Hello Shay,
>
> > I have a years using compass, now I see elasticsearch, I want to play
> > with it.
>
> > With ElasticSearch I could do:
> > 1) in  "search"  return a json structure different from the index?.
>
> > Example:
> > index:
> > {
> >    "User": "kimchy"
> >    "PostData": "2009-11-15T14: 12:12"
> >    "Message": "trying out Elastic Search"
> > }
>
> > and search:
> > {
> >    "_shards": {
> >        "Total": 5,
> >        "Successful": 5,
> >        "Failed": 0
> >    }
> >    "Hits": {
> >        "Total": 1,
> >        "Hits": [
> >            {
> >                "_index": "Twitter"
> >                "_type": "Tweet"
> >                "_id": "1"
> >                "_source": {
> >                    "User": "kimchy"
> >                    "Today": "2010-04-15T14: 12:12", / / calculated
> > dynamically, today's date
> >                    "Message": "trying out Elastic Search"
> >                    "Days": 180 / / calculated dynamically, the rest
> > of today-postData
> >                }
> >            }
> >        ]
> >    }
> > }
>
> > Moreover, in some cases might omit some control information, do not
> > send "_index", "_type", and "_id". This is possible?
>
> > 2) I'm thinking that elasticsearch respond directly to requests from a
> > browser.
> > A website made  jsonp requests to search in elasticsearch, and respond
> > json for rendering in browser with PURE (http://beebole.com/pure/)
> > Think this solution is viable
>
> > Thanks, and sorry for my language mistakes
Reply | Threaded
Open this post in threaded view
|

Re: Change the structure of response json

kimchy
Administrator
This can be done, but will be less powerful then what I suggested since in the template, you will only have access to the response you got, and not additional data (for example, when searching). This can also be developed as a plugin, btw.

cheers,
shay.banon

On Thu, Apr 22, 2010 at 5:02 AM, tfreitas <[hidden email]> wrote:
What do you think about having "templates" response on the server?.
Could do this as a module in elasticsearch?

On Apr 21, 1:35 pm, Shay Banon <[hidden email]> wrote:
> Hi,
>
> Regarding the first question, I am thinking of something very similar to
> enable in elasticsearch. Basically, allow to augment the results with more
> information. I have an idea on how to do this, but it will be at least 0.8
> before I will try and tackle this. For now, you can front elasticsearch with
> your own server that augments the data.
>
> cheers,
> shay.banon
>
> On Wed, Apr 21, 2010 at 5:41 AM, tfreitas <[hidden email]> wrote:
> > Hello Shay,
>
> > I have a years using compass, now I see elasticsearch, I want to play
> > with it.
>
> > With ElasticSearch I could do:
> > 1) in  "search"  return a json structure different from the index?.
>
> > Example:
> > index:
> > {
> >    "User": "kimchy"
> >    "PostData": "2009-11-15T14: 12:12"
> >    "Message": "trying out Elastic Search"
> > }
>
> > and search:
> > {
> >    "_shards": {
> >        "Total": 5,
> >        "Successful": 5,
> >        "Failed": 0
> >    }
> >    "Hits": {
> >        "Total": 1,
> >        "Hits": [
> >            {
> >                "_index": "Twitter"
> >                "_type": "Tweet"
> >                "_id": "1"
> >                "_source": {
> >                    "User": "kimchy"
> >                    "Today": "2010-04-15T14: 12:12", / / calculated
> > dynamically, today's date
> >                    "Message": "trying out Elastic Search"
> >                    "Days": 180 / / calculated dynamically, the rest
> > of today-postData
> >                }
> >            }
> >        ]
> >    }
> > }
>
> > Moreover, in some cases might omit some control information, do not
> > send "_index", "_type", and "_id". This is possible?
>
> > 2) I'm thinking that elasticsearch respond directly to requests from a
> > browser.
> > A website made  jsonp requests to search in elasticsearch, and respond
> > json for rendering in browser with PURE (http://beebole.com/pure/)
> > Think this solution is viable
>
> > Thanks, and sorry for my language mistakes

Reply | Threaded
Open this post in threaded view
|

Re: Change the structure of response json

tfreitas
ok, I'm going to use a server front, and watch out for this
functionality you mention, would be great.
Thanks for your work and effort


On Apr 22, 3:15 am, Shay Banon <[hidden email]> wrote:

> This can be done, but will be less powerful then what I suggested since in
> the template, you will only have access to the response you got, and not
> additional data (for example, when searching). This can also be developed as
> a plugin, btw.
>
> cheers,
> shay.banon
>
> On Thu, Apr 22, 2010 at 5:02 AM, tfreitas <[hidden email]> wrote:
> > What do you think about having "templates" response on the server?.
> > Could do this as a module in elasticsearch?
>
> > On Apr 21, 1:35 pm, Shay Banon <[hidden email]> wrote:
> > > Hi,
>
> > > Regarding the first question, I am thinking of something very similar to
> > > enable in elasticsearch. Basically, allow to augment the results with
> > more
> > > information. I have an idea on how to do this, but it will be at least
> > 0.8
> > > before I will try and tackle this. For now, you can front elasticsearch
> > with
> > > your own server that augments the data.
>
> > > cheers,
> > > shay.banon
>
> > > On Wed, Apr 21, 2010 at 5:41 AM, tfreitas <[hidden email]> wrote:
> > > > Hello Shay,
>
> > > > I have a years using compass, now I see elasticsearch, I want to play
> > > > with it.
>
> > > > With ElasticSearch I could do:
> > > > 1) in  "search"  return a json structure different from the index?.
>
> > > > Example:
> > > > index:
> > > > {
> > > >    "User": "kimchy"
> > > >    "PostData": "2009-11-15T14: 12:12"
> > > >    "Message": "trying out Elastic Search"
> > > > }
>
> > > > and search:
> > > > {
> > > >    "_shards": {
> > > >        "Total": 5,
> > > >        "Successful": 5,
> > > >        "Failed": 0
> > > >    }
> > > >    "Hits": {
> > > >        "Total": 1,
> > > >        "Hits": [
> > > >            {
> > > >                "_index": "Twitter"
> > > >                "_type": "Tweet"
> > > >                "_id": "1"
> > > >                "_source": {
> > > >                    "User": "kimchy"
> > > >                    "Today": "2010-04-15T14: 12:12", / / calculated
> > > > dynamically, today's date
> > > >                    "Message": "trying out Elastic Search"
> > > >                    "Days": 180 / / calculated dynamically, the rest
> > > > of today-postData
> > > >                }
> > > >            }
> > > >        ]
> > > >    }
> > > > }
>
> > > > Moreover, in some cases might omit some control information, do not
> > > > send "_index", "_type", and "_id". This is possible?
>
> > > > 2) I'm thinking that elasticsearch respond directly to requests from a
> > > > browser.
> > > > A website made  jsonp requests to search in elasticsearch, and respond
> > > > json for rendering in browser with PURE (http://beebole.com/pure/)
> > > > Think this solution is viable
>
> > > > Thanks, and sorry for my language mistakes
>
>