URI Request that returns just the _source, without metadata?


(Eric Jain) #1

e.g. for 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy' I get:

{
"_shards":{
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits":{
"total" : 1,
"hits" : [
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_source" : {
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
}
]
}
}

But sometimes it would be more useful to have:

{
...
"hits":{
"total" : 1,
"hits" : [
{
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
]
}
}

Is there an option for this, or if not, would this be a useful addition?


(Martijn Van Groningen) #2

Hi Eric,

I think the field request parameter will suite your needs:
http://www.elasticsearch.org/guide/reference/api/search/fields.html

Martijn

On 2 August 2012 20:41, Eric Jain eric.jain@gmail.com wrote:

e.g. for 'http://localhost:9200/twitter/tweet/_search?q=user:kimchy' I get:

{
"_shards":{
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits":{
"total" : 1,
"hits" : [
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"_source" : {
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
}
]
}
}

But sometimes it would be more useful to have:

{
...
"hits":{
"total" : 1,
"hits" : [
{
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
]
}
}

Is there an option for this, or if not, would this be a useful addition?

--
Met vriendelijke groet,

Martijn van Groningen


(Eric Jain) #3

On Fri, Aug 3, 2012 at 4:56 AM, Martijn v Groningen
martijn.v.groningen@gmail.com wrote:

I think the field request parameter will suite your needs:
http://www.elasticsearch.org/guide/reference/api/search/fields.html

"_source" is the default already; the question is how to get the
contents of the _source unwrapped.


(phill) #4

Eric,

Can't you request _source.user, _source.postDate etc. with some
appropriate notation?

-Paul
On 8/3/2012 10:16 AM, Eric Jain wrote:

On Fri, Aug 3, 2012 at 4:56 AM, Martijn v Groningen
martijn.v.groningen@gmail.com wrote:

I think the field request parameter will suite your needs:
http://www.elasticsearch.org/guide/reference/api/search/fields.html
"_source" is the default already; the question is how to get the
contents of the _source unwrapped.


(Eric Jain) #5

On Fri, Aug 3, 2012 at 6:47 PM, P.Hill parehill1@gmail.com wrote:

Can't you request _source.user, _source.postDate etc. with some appropriate
notation?

Then I get:

"hits" : [
{
"_index" : "twitter",
"_type" : "tweet",
"_id" : "1",
"fields" : {
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
}
]

But what I want is:

"hits" : [
{
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
}
]

It's not a big deal, but it would be useful to have a quick and
convenient way to "dump" the original _source data, with no
elasticsearch metadata.


(Clinton Gormley) #6

But what I want is:

"hits" : [
{
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
}
]

It's not a big deal, but it would be useful to have a quick and
convenient way to "dump" the original _source data, with no
elasticsearch metadata.

It's not supported. You always get the metadata I'm afraid

clint


(Shay Banon) #7

We can potentially support it, should be simple enough actually. Want to open an issue?

On Aug 6, 2012, at 1:36 PM, Clinton Gormley clint@traveljury.com wrote:

But what I want is:

"hits" : [
{
"user" : "kimchy",
"postDate" : "2009-11-15T14:12:12",
"message" : "trying out Elastic Search"
}
}
]

It's not a big deal, but it would be useful to have a quick and
convenient way to "dump" the original _source data, with no
elasticsearch metadata.

It's not supported. You always get the metadata I'm afraid

clint


(Eric Jain) #8

On Tue, Aug 7, 2012 at 2:41 PM, Shay Banon kimchy@gmail.com wrote:

We can potentially support it, should be simple enough actually. Want to open an issue?


(phill) #9

Would that simply be an extra parameter on the URI, for example brief=1

http://localhost:9200/twitter/tweet/_search?q=user:kimchy&pretty=1&brief=1

Maybe using a name which could be re-used elsewhere in requests where
"just the data please" might come in handy.

-Paul

On 8/7/2012 5:42 PM, Eric Jain wrote:

On Tue, Aug 7, 2012 at 2:41 PM, Shay Banon kimchy@gmail.com wrote:

We can potentially support it, should be simple enough actually. Want to open an issue?
https://github.com/elasticsearch/elasticsearch/issues/2149

--


(system) #10