Can elasticsearch list the latest X number of indexed documents across all indexes?

Hi
I'm a complete elasticsearch/lucene newbie and I've been given a
requirement which I'm wondering if elasticsearch can help me with.

I work on a Grails application where we have a bunch of information which
we would like to display to users in a "timeline" fashion, a bit on their
welcome page where we list the latest news, articles, document uploads, etc.
All these grails domain objects have a lastUpdated timestamp which I'm
hoping to order by, as well as provide some index specific criteria if
possible.

First off is it possible to simply fetch the latest X number of documents
without any filtering by query parameters?

Sorry for this trivial question but thought I'd go down the lazy route and
simply ask :slight_smile:

Many thanks,
Micke

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

When a document goes to ES, ES by itself (if not provided) just gives it a
id and parses fields etc. It doesn't have any notion of when was the
document added.

So, you'll have to have a field that'll keep track of when a doc was added.

On Wed, Jun 5, 2013 at 1:11 AM, Mikael Andersson mail.micke@gmail.comwrote:

Hi
I'm a complete elasticsearch/lucene newbie and I've been given a
requirement which I'm wondering if elasticsearch can help me with.

I work on a Grails application where we have a bunch of information which
we would like to display to users in a "timeline" fashion, a bit on their
welcome page where we list the latest news, articles, document uploads, etc.
All these grails domain objects have a lastUpdated timestamp which I'm
hoping to order by, as well as provide some index specific criteria if
possible.

First off is it possible to simply fetch the latest X number of documents
without any filtering by query parameters?

Sorry for this trivial question but thought I'd go down the lazy route and
simply ask :slight_smile:

Many thanks,
Micke

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,
Abhijeet Rastogi (shadyabhi)

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hey,

you could simply sort the documents by the last updated timestamp and do a
query_all query, plus specifying the size, like this for your tests

curl -X POST localhost:9200/twitter/tweet/_search -d '{ "size":5, "query" :
{ "match_all":{} } , "sort" : [ { "_timestamp" : { "order":"asc" } } ] }'

hope this helps

--Alex

On Tue, Jun 4, 2013 at 9:41 PM, Mikael Andersson mail.micke@gmail.comwrote:

Hi
I'm a complete elasticsearch/lucene newbie and I've been given a
requirement which I'm wondering if elasticsearch can help me with.

I work on a Grails application where we have a bunch of information which
we would like to display to users in a "timeline" fashion, a bit on their
welcome page where we list the latest news, articles, document uploads, etc.
All these grails domain objects have a lastUpdated timestamp which I'm
hoping to order by, as well as provide some index specific criteria if
possible.

First off is it possible to simply fetch the latest X number of documents
without any filtering by query parameters?

Sorry for this trivial question but thought I'd go down the lazy route and
simply ask :slight_smile:

Many thanks,
Micke

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

FYI, the timestamp feature is disabled by default:
http://www.elasticsearch.org/guide/reference/mapping/timestamp-field/

Enabling it with the defaults and using Alex's example would be the ideal
solution.

--
Ivan

On Wed, Jun 5, 2013 at 8:51 AM, Alexander Reelsen alr@spinscale.de wrote:

Hey,

you could simply sort the documents by the last updated timestamp and do a
query_all query, plus specifying the size, like this for your tests

curl -X POST localhost:9200/twitter/tweet/_search -d '{ "size":5, "query"
: { "match_all":{} } , "sort" : [ { "_timestamp" : { "order":"asc" } } ] }'

hope this helps

--Alex

On Tue, Jun 4, 2013 at 9:41 PM, Mikael Andersson mail.micke@gmail.comwrote:

Hi
I'm a complete elasticsearch/lucene newbie and I've been given a
requirement which I'm wondering if elasticsearch can help me with.

I work on a Grails application where we have a bunch of information which
we would like to display to users in a "timeline" fashion, a bit on their
welcome page where we list the latest news, articles, document uploads, etc.
All these grails domain objects have a lastUpdated timestamp which I'm
hoping to order by, as well as provide some index specific criteria if
possible.

First off is it possible to simply fetch the latest X number of documents
without any filtering by query parameters?

Sorry for this trivial question but thought I'd go down the lazy route
and simply ask :slight_smile:

Many thanks,
Micke

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Brilliant

Been playing around with this and indeed it does seem to do exactly what I
want, even by simply switching the _timestamp for in my case lastUpdated.

Next step is to figure out how I can add custom filtering to each of the
different documents : )

Many thanks for the info, just what I needed.

  • Micke

On Wednesday, June 5, 2013 4:51:04 PM UTC+1, Alexander Reelsen wrote:

Hey,

you could simply sort the documents by the last updated timestamp and do a
query_all query, plus specifying the size, like this for your tests

curl -X POST localhost:9200/twitter/tweet/_search -d '{ "size":5, "query"
: { "match_all":{} } , "sort" : [ { "_timestamp" : { "order":"asc" } } ] }'

hope this helps

--Alex

On Tue, Jun 4, 2013 at 9:41 PM, Mikael Andersson <mail....@gmail.com<javascript:>

wrote:

Hi
I'm a complete elasticsearch/lucene newbie and I've been given a
requirement which I'm wondering if elasticsearch can help me with.

I work on a Grails application where we have a bunch of information which
we would like to display to users in a "timeline" fashion, a bit on their
welcome page where we list the latest news, articles, document uploads, etc.
All these grails domain objects have a lastUpdated timestamp which I'm
hoping to order by, as well as provide some index specific criteria if
possible.

First off is it possible to simply fetch the latest X number of documents
without any filtering by query parameters?

Sorry for this trivial question but thought I'd go down the lazy route
and simply ask :slight_smile:

Many thanks,
Micke

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearc...@googlegroups.com <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Hey,

just a side note, if the entities you are indexing are GORM based entities,
you simply index the lastUpdated timestamp, make sure it is a timestamp
when indexing, and do not need the _timestamp functionality at all.

But maybe I got you wrong here, so if you current solution works, I am fine
with that as well :wink:

--Alex

On Wed, Jun 5, 2013 at 11:27 PM, Mikael Andersson mail.micke@gmail.comwrote:

Brilliant

Been playing around with this and indeed it does seem to do exactly what I
want, even by simply switching the _timestamp for in my case lastUpdated.

Next step is to figure out how I can add custom filtering to each of the
different documents : )

Many thanks for the info, just what I needed.

  • Micke

On Wednesday, June 5, 2013 4:51:04 PM UTC+1, Alexander Reelsen wrote:

Hey,

you could simply sort the documents by the last updated timestamp and do
a query_all query, plus specifying the size, like this for your tests

curl -X POST localhost:9200/twitter/tweet/_**search -d '{ "size":5,
"query" : { "match_all":{} } , "sort" : [ { "_timestamp" : { "order":"asc"
} } ] }'

hope this helps

--Alex

On Tue, Jun 4, 2013 at 9:41 PM, Mikael Andersson mail....@gmail.comwrote:

Hi
I'm a complete elasticsearch/lucene newbie and I've been given a
requirement which I'm wondering if elasticsearch can help me with.

I work on a Grails application where we have a bunch of information
which we would like to display to users in a "timeline" fashion, a bit on
their welcome page where we list the latest news, articles, document
uploads, etc.
All these grails domain objects have a lastUpdated timestamp which I'm
hoping to order by, as well as provide some index specific criteria if
possible.

First off is it possible to simply fetch the latest X number of
documents without any filtering by query parameters?

Sorry for this trivial question but thought I'd go down the lazy route
and simply ask :slight_smile:

Many thanks,
Micke

--
You received this message because you are subscribed to the Google
Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to elasticsearc...@**googlegroups.com.

For more options, visit https://groups.google.com/**groups/opt_outhttps://groups.google.com/groups/opt_out
.

--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.