Sort based on day

Hi ,

I am trying to implement a sort on the resulting set based on following
criteria

  • Last 24 hours of data should get the highest priority. Previous should
    be getting the next and so on. ( I have a time feild which stores the time
    of the feed)
  • And on a the last 24 hours of feeds , the feed with greatest value for
    the field count should come first. The same with the rest.

So this is a combination of time field and number field.

How can this be achieved using sort ?

Thanks

        Vineeth

--
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 Vineeth,

I think "Script based sorting" is what you need:

E.g.

{
"query" : {
....
},
"sort" : {
"_script" : {
"script" : "doc['field_name'].value * factor",
"type" : "number",
"params" : {
"factor" : 1.1
},
"order" : "asc"
}
}
}

Best regards,

Robin Verlangen
Data Architect
*
*
W http://www.robinverlangen.nl
E robin@us2.nl

http://goo.gl/Lt7BC

Disclaimer: The information contained in this message and attachments is
intended solely for the attention and use of the named addressee and may be
confidential. If you are not the intended recipient, you are reminded that
the information remains the property of the sender. You must not use,
disclose, distribute, copy, print or rely on this e-mail. If you have
received this message in error, please contact the sender immediately and
irrevocably delete this message and any copies.

On Mon, May 6, 2013 at 6:23 AM, Vineeth Mohan vineethmohan@algotree.comwrote:

Hi ,

I am trying to implement a sort on the resulting set based on following
criteria

  • Last 24 hours of data should get the highest priority. Previous
    should be getting the next and so on. ( I have a time feild which stores
    the time of the feed)
  • And on a the last 24 hours of feeds , the feed with greatest value
    for the field count should come first. The same with the rest.

So this is a combination of time field and number field.

How can this be achieved using sort ?

Thanks

        Vineeth

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

Add a boost to your documents in respect to the time stamp value.

Idea is to use timestamp for boost, e.g. 1.0 = day 1, 2.0 = day 2, 3.0 =
day 3 ... n = day n

Then you do not need to sort. Sort is evil.

Jörg

Am 06.05.13 06:23, schrieb Vineeth Mohan:

Hi ,

I am trying to implement a sort on the resulting set based on
following criteria

  • Last 24 hours of data should get the highest priority. Previous
    should be getting the next and so on. ( I have a time feild which
    stores the time of the feed)
  • And on a the last 24 hours of feeds , the feed with greatest value
    for the field count should come first. The same with the rest.

So this is a combination of time field and number field.

How can this be achieved using sort ?

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