0.90.4 recency example for Function Score Query


(kevins) #1

I would like to apply recency to a simple match query.

I was heading in the direction of using _timestamp in a script such as
this: "script": "_score + log(doc['_timestamp'].value)/100"

However, after reading this post regarding 90.4 function_score_query I am
confused. The document mentions recency and then goes on to use a geo
distance example. Does an example of applying recency exist?

In my use case recent docs would have some minor influence and docs older
than say a year would have 0.

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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/01593ddc-94bb-4fa0-8d56-aa3014a9f8b3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Adrien Grand) #2

Hi Kevin,

There are examples on the function_score documentation page about dates and
prices that should help:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

Don't hesitate to let me know if it doesn't!

On Tue, Nov 26, 2013 at 9:53 PM, Kevin S kevinsteger@gmail.com wrote:

I would like to apply recency to a simple match query.

I was heading in the direction of using _timestamp in a script such as
this: "script": "_score + log(doc['_timestamp'].value)/100"

However, after reading this post regarding 90.4 function_score_query I am
confused. The document mentions recency and then goes on to use a geo
distance example. Does an example of applying recency exist?

In my use case recent docs would have some minor influence and docs older
than say a year would have 0.

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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/01593ddc-94bb-4fa0-8d56-aa3014a9f8b3%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4ucbv7%3Dv%3Dqt-XYmexNrEipdQrfnwbKpv6zM9EZyVNGKg%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(kevins) #3

That is the page I intended to link to in my original post.

It is still not clear how to use _timestamp in the calculations.

What I would love to see in an example that would contrast: Heavy weight
on _score, light on recency. vs Heavy on recency, light on _score.

This functionality was very easy to do on the platform I am moving from
where an "age" variable was available allowing calculations such as: (-age

  • relevance^2) or (-age^2 + relevance). I'm trying to duplicate that.

Thanks.

On Wednesday, November 27, 2013 3:03:30 AM UTC-8, Adrien Grand wrote:

Hi Kevin,

There are examples on the function_score documentation page about dates
and prices that should help:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

Don't hesitate to let me know if it doesn't!

On Tue, Nov 26, 2013 at 9:53 PM, Kevin S <kevin...@gmail.com <javascript:>

wrote:

I would like to apply recency to a simple match query.

I was heading in the direction of using _timestamp in a script such as
this: "script": "_score + log(doc['_timestamp'].value)/100"

However, after reading this post regarding 90.4 function_score_query I am
confused. The document mentions recency and then goes on to use a geo
distance example. Does an example of applying recency exist?

In my use case recent docs would have some minor influence and docs older
than say a year would have 0.

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:>.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/01593ddc-94bb-4fa0-8d56-aa3014a9f8b3%40googlegroups.com
.
For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/d1ce1614-e980-4169-b4a7-548aa751f61b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


(Britta Weber) #4

Hi Kevin,

if you need arbitrarily complex functions, I think the script score as
you described is most useful. But you have to compute distance and
decay yourself in the script.
The decay functions are separate from the script scoring and can only
be combined with other functions as described in the documentation
(sum, avg,...). The only weighting can be achieved in a sum by using a
"bool" query with "disable_coord": true.
I hope that helps.

Cheers,
Britta

On Fri, Nov 29, 2013 at 5:39 AM, Kevin S kevinsteger@gmail.com wrote:

That is the page I intended to link to in my original post.

It is still not clear how to use _timestamp in the calculations.

What I would love to see in an example that would contrast: Heavy weight on
_score, light on recency. vs Heavy on recency, light on _score.

This functionality was very easy to do on the platform I am moving from
where an "age" variable was available allowing calculations such as: (-age +
relevance^2) or (-age^2 + relevance). I'm trying to duplicate that.

Thanks.

On Wednesday, November 27, 2013 3:03:30 AM UTC-8, Adrien Grand wrote:

Hi Kevin,

There are examples on the function_score documentation page about dates
and prices that should help:

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html

Don't hesitate to let me know if it doesn't!

On Tue, Nov 26, 2013 at 9:53 PM, Kevin S kevin...@gmail.com wrote:

I would like to apply recency to a simple match query.

I was heading in the direction of using _timestamp in a script such as
this: "script": "_score + log(doc['_timestamp'].value)/100"

However, after reading this post regarding 90.4 function_score_query I am
confused. The document mentions recency and then goes on to use a geo
distance example. Does an example of applying recency exist?

In my use case recent docs would have some minor influence and docs older
than say a year would have 0.

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.

To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/01593ddc-94bb-4fa0-8d56-aa3014a9f8b3%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Adrien Grand

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/d1ce1614-e980-4169-b4a7-548aa751f61b%40googlegroups.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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CALhJbBhpvJHjCy0GyjjiBCfEYHx7DqCEu3q9nU0_ShAzUXAj5Q%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


(system) #5