Change the structure of response json


(tfreitas) #1

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?

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


(Shay Banon) #2

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 tfreitas@gmail.com 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?

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


(tfreitas) #3

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 shay.ba...@elasticsearch.com 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 tfrei...@gmail.com 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?

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


(Shay Banon) #4

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 tfreitas@gmail.com 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 shay.ba...@elasticsearch.com 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 tfrei...@gmail.com 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?

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


(tfreitas) #5

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 shay.ba...@elasticsearch.com 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 tfrei...@gmail.com 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 shay.ba...@elasticsearch.com 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 tfrei...@gmail.com 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?

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


(system) #6