Maximum value of an inexed field

Hi,

I was wondering what is the best way to get the maximum value of an indexed
field?
For example I have a document with a field named "localTime" and i want to
take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

--
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 may want to have a look at statistical facets. They are building an
aggregation module but I don't believe it has been finished or released.

Nik

On Wed, Aug 14, 2013 at 12:54 PM, Thomas thomas.bolis@gmail.com wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want to
take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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

instead of faceting you can just do a reverse sort on that field?

simon

On Wednesday, August 14, 2013 6:58:59 PM UTC+2, Nikolas Everett wrote:

You may want to have a look at statistical facets. They are building an
aggregation module but I don't believe it has been finished or released.

Nik

On Wed, Aug 14, 2013 at 12:54 PM, Thomas <thomas...@gmail.com<javascript:>

wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want
to take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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

Hi,

Thanks for the replies, very helpful! I was thinking the solution of the
reverse sorting, but I was wondering how fast n' efficient is this?
probably will go that direction (sorting) till the new feature Nik is
mentioning will be released..

T.

On 08/14/2013 10:09 PM, simonw wrote:

instead of faceting you can just do a reverse sort on that field?

simon

On Wednesday, August 14, 2013 6:58:59 PM UTC+2, Nikolas Everett wrote:

You may want to have a look at statistical facets.  They are
building an aggregation module but I don't believe it has been
finished or released.


Nik

On Wed, Aug 14, 2013 at 12:54 PM, Thomas <thomas...@gmail.com
<javascript:>> wrote:

    Hi,

    I was wondering what is the best way to get the maximum value
    of an indexed field?
    For example I have a document with a field named "localTime"
    and i want to take the maximum value of that field. Is the
    only way to do that the StatisticsFacet getMax method? Can
    somehow filter the results to return to me the document(s)
    that have this maximum value and then get the field I want?

    Thank you
    -- 
    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
    <https://groups.google.com/groups/opt_out>.

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/H9syKXvazH0/unsubscribe.
To unsubscribe from this group and all its topics, 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.

@Thomas, reverse sorting is likely as efficient as it gets even in the
future. Aggregations will likely be slower.

simon

On Saturday, August 17, 2013 1:21:05 AM UTC+2, Thomas wrote:

Hi,

Thanks for the replies, very helpful! I was thinking the solution of the
reverse sorting, but I was wondering how fast n' efficient is this?
probably will go that direction (sorting) till the new feature Nik is
mentioning will be released..

T.

On 08/14/2013 10:09 PM, simonw wrote:

instead of faceting you can just do a reverse sort on that field?

simon

On Wednesday, August 14, 2013 6:58:59 PM UTC+2, Nikolas Everett wrote:

You may want to have a look at statistical facets. They are building an
aggregation module but I don't believe it has been finished or released.

Nik

On Wed, Aug 14, 2013 at 12:54 PM, Thomas thomas...@gmail.com wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want
to take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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

--
You received this message because you are subscribed to a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/H9syKXvazH0/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Hi,

Thanks guys!
I contuinue with this and I implement the sort solution to get the maximum
value but I note something else; in the results i try to get the max value
returned of a date value like this:

java.util.Date max =
response.getHits().getHits()[0].field(field.getName()).getValue();

But the value returned is always string, (I have also tryied to do it with
a Long field). Is this correct? I note tha the signature of the getValue is

V getValue();

meaning tha should support my casting to Date since the field is declared
as date field, or I'm missing something:

logDate: {
"index": "analyzed",
"format": "dateOptionalTime"
"type": "date"
}

Thank you in advance
Tom

On Sat, Aug 17, 2013 at 9:11 AM, simonw
simon.willnauer@elasticsearch.comwrote:

@Thomas, reverse sorting is likely as efficient as it gets even in the
future. Aggregations will likely be slower.

simon

On Saturday, August 17, 2013 1:21:05 AM UTC+2, Thomas wrote:

Hi,

Thanks for the replies, very helpful! I was thinking the solution of the
reverse sorting, but I was wondering how fast n' efficient is this?
probably will go that direction (sorting) till the new feature Nik is
mentioning will be released..

T.

On 08/14/2013 10:09 PM, simonw wrote:

instead of faceting you can just do a reverse sort on that field?

simon

On Wednesday, August 14, 2013 6:58:59 PM UTC+2, Nikolas Everett wrote:

You may want to have a look at statistical facets. They are building an
aggregation module but I don't believe it has been finished or released.

Nik

On Wed, Aug 14, 2013 at 12:54 PM, Thomas thomas...@gmail.com wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want
to take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/**H9syKXvazH0/unsubscribehttps://groups.google.com/d/topic/elasticsearch/H9syKXvazH0/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/H9syKXvazH0/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Hi, I want to add a correction here, this is happening in the date field
only i tried with other types of fields, and worked fine

On Mon, Aug 19, 2013 at 10:34 AM, Thomas Bolis thomas.bolis@gmail.comwrote:

Hi,

Thanks guys!
I contuinue with this and I implement the sort solution to get the maximum
value but I note something else; in the results i try to get the max value
returned of a date value like this:

java.util.Date max =
response.getHits().getHits()[0].field(field.getName()).getValue();

But the value returned is always string, (I have also tryied to do it with
a Long field). Is this correct? I note tha the signature of the getValue is

V getValue();

meaning tha should support my casting to Date since the field is declared
as date field, or I'm missing something:

logDate: {
"index": "analyzed",
"format": "dateOptionalTime"
"type": "date"
}

Thank you in advance
Tom

On Sat, Aug 17, 2013 at 9:11 AM, simonw <simon.willnauer@elasticsearch.com

wrote:

@Thomas, reverse sorting is likely as efficient as it gets even in the
future. Aggregations will likely be slower.

simon

On Saturday, August 17, 2013 1:21:05 AM UTC+2, Thomas wrote:

Hi,

Thanks for the replies, very helpful! I was thinking the solution of the
reverse sorting, but I was wondering how fast n' efficient is this?
probably will go that direction (sorting) till the new feature Nik is
mentioning will be released..

T.

On 08/14/2013 10:09 PM, simonw wrote:

instead of faceting you can just do a reverse sort on that field?

simon

On Wednesday, August 14, 2013 6:58:59 PM UTC+2, Nikolas Everett wrote:

You may want to have a look at statistical facets. They are building
an aggregation module but I don't believe it has been finished or released.

Nik

On Wed, Aug 14, 2013 at 12:54 PM, Thomas thomas...@gmail.com wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i
want to take the maximum value of that field. Is the only way to do that
the StatisticsFacet getMax method? Can somehow filter the results to return
to me the document(s) that have this maximum value and then get the field I
want?

Thank you

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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/**H9syKXvazH0/unsubscribehttps://groups.google.com/d/topic/elasticsearch/H9syKXvazH0/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/H9syKXvazH0/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Finally, I wasn't able to figure this out.. A possible bug?

Thanks
Tom

On Mon, Aug 19, 2013 at 11:10 AM, Thomas Bolis thomas.bolis@gmail.comwrote:

Hi, I want to add a correction here, this is happening in the date field
only i tried with other types of fields, and worked fine

On Mon, Aug 19, 2013 at 10:34 AM, Thomas Bolis thomas.bolis@gmail.comwrote:

Hi,

Thanks guys!
I contuinue with this and I implement the sort solution to get the
maximum value but I note something else; in the results i try to get the
max value returned of a date value like this:

java.util.Date max =
response.getHits().getHits()[0].field(field.getName()).getValue();

But the value returned is always string, (I have also tryied to do it
with a Long field). Is this correct? I note tha the signature of the
getValue is

V getValue();

meaning tha should support my casting to Date since the field is declared
as date field, or I'm missing something:

logDate: {
"index": "analyzed",
"format": "dateOptionalTime"
"type": "date"
}

Thank you in advance
Tom

On Sat, Aug 17, 2013 at 9:11 AM, simonw <
simon.willnauer@elasticsearch.com> wrote:

@Thomas, reverse sorting is likely as efficient as it gets even in the
future. Aggregations will likely be slower.

simon

On Saturday, August 17, 2013 1:21:05 AM UTC+2, Thomas wrote:

Hi,

Thanks for the replies, very helpful! I was thinking the solution of
the reverse sorting, but I was wondering how fast n' efficient is this?
probably will go that direction (sorting) till the new feature Nik is
mentioning will be released..

T.

On 08/14/2013 10:09 PM, simonw wrote:

instead of faceting you can just do a reverse sort on that field?

simon

On Wednesday, August 14, 2013 6:58:59 PM UTC+2, Nikolas Everett wrote:

You may want to have a look at statistical facets. They are building
an aggregation module but I don't believe it has been finished or released.

Nik

On Wed, Aug 14, 2013 at 12:54 PM, Thomas thomas...@gmail.com wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i
want to take the maximum value of that field. Is the only way to do that
the StatisticsFacet getMax method? Can somehow filter the results to return
to me the document(s) that have this maximum value and then get the field I
want?

Thank you

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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/**
topic/elasticsearch/**H9syKXvazH0/unsubscribehttps://groups.google.com/d/topic/elasticsearch/H9syKXvazH0/unsubscribe
.
To unsubscribe from this group and all its topics, 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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/H9syKXvazH0/unsubscribe.
To unsubscribe from this group and all its topics, 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.

Finally, I wasn't able to figure this out.. A possible bug?

Thanks
Tom

On Wednesday, August 14, 2013 7:54:21 PM UTC+3, Thomas wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want to
take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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

I am not sure I can follow you. What is a possible bug?

On Monday, August 19, 2013 7:10:52 PM UTC+2, Thomas wrote:

Finally, I wasn't able to figure this out.. A possible bug?

Thanks
Tom

On Wednesday, August 14, 2013 7:54:21 PM UTC+3, Thomas wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want
to take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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

Hi Simonw,

Sorry for not explaining well,

What i mean is that i try to retrieve the value as a date but the actual
value is of type string, having as a result a cast exception:

java.util.Date date =
response.getHits().getHits()[0].field("logDate").getValue(); // Although in
my mapping the field is of type date, the value returned is of type String

For other java types this works fine:

Double counter =
response.getHits().getHits()[0].field("counter").getValue(); // Works fine

Does this makes sense?

thanks again
T.

On Wednesday, 14 August 2013 19:54:21 UTC+3, Thomas wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want to
take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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

Unfortunately we can't return this as a date at this point. You have to
parse the string back into a date. This is expected behavior.

simon

On Monday, August 19, 2013 9:11:14 PM UTC+2, Thomas wrote:

Hi Simonw,

Sorry for not explaining well,

What i mean is that i try to retrieve the value as a date but the actual
value is of type string, having as a result a cast exception:

java.util.Date date =
response.getHits().getHits()[0].field("logDate").getValue(); // Although in
my mapping the field is of type date, the value returned is of type String

For other java types this works fine:

Double counter =
response.getHits().getHits()[0].field("counter").getValue(); // Works fine

Does this makes sense?

thanks again
T.

On Wednesday, 14 August 2013 19:54:21 UTC+3, Thomas wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want
to take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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

Thank you again for your help, yes this is the case I return it as a String
and parse it back to Date

Tom

On Wednesday, August 14, 2013 7:54:21 PM UTC+3, Thomas wrote:

Hi,

I was wondering what is the best way to get the maximum value of an
indexed field?
For example I have a document with a field named "localTime" and i want to
take the maximum value of that field. Is the only way to do that the
StatisticsFacet getMax method? Can somehow filter the results to return to
me the document(s) that have this maximum value and then get the field I
want?

Thank you

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