Reputation: 173
I'm using elasticpress on a project. I have included on the index a meta_field where I want to make matches (more important than title or anything else)
On pre_get_post I do the following:
$query->set( 'search_fields', array(
'meta' => array( 'meta_title' ),
'post_content',
'post_excerpt',
) );
I'm able to fetch the matches for that meta, but I need to sort them by date, that means, given the matches, give more weight to recent posts.
I believe I have to use a decay function here, but I'm not totally sure if that's the best way.
Any ideas?
P.s: This is the exp function it is being used, but it seems it is not working properly
"exp": {
"post_date_gmt": {
"scale": "14d",
"decay": 0.25,
"offset": "7d"
}
},
Upvotes: 1
Views: 353
Reputation: 51
Yep, a decay function is what you want. That is a pretty strong decay you are using, so maybe your function_score query is not properly wrapping the overall query. It looks like ElasticPress has debug bar support, so maybe that will help you see what is wrong with the query.
I've typically found gaussian decays a bit smoother. Some examples of things I've used are:
Upvotes: 1