QUESTION: Related Posts options
Hi there. I have last WP version 6.0.2 and ElasticPress plugin 4.3.0. I also have a website with 70,000 entries. I am using the function Related Posts. The results are not relevant. In some cases, there are none at all or only 1 post (out of 5 requested). Tell me, on what principle does the issuance of posts work Related Posts? Are there any options?
Hi @ws256 ,
Fields used are the following: https://github.com/10up/ElasticPress/blob/develop/includes/classes/Feature/RelatedPosts/RelatedPosts.php#L75
It's hard to determine why without knowing your website, but I've seen cases where content is built with ACF, in that case ElasticPress is not looking at these fields, for example.
You can learn more about the query that's being used here: elastic.co/guide/en/elasticsearch/reference/current/query-dsl-mlt-query.html
Thanks, @oscarssanchez In order for related posts to work correctly, we have added a filter that removes from the array: 'post_content'. And added forced sorting 'orderby' => 'relevance' Why isn't it available by default for users and related posts? After these manipulations, the issuance of posts became correct, where it was not at all - it appeared.
Hi @ws256 ,
I guess I don't fully understand what you say. Can you clarify what are the expectations ?
Thanks!
Related Posts is a display of related posts in terms of content. Not random, not with the same one word in the title. Above, I wrote what I had to do to get exactly the "related records".
public function ep_related_posts_fields($arr)
{
$arr = [
'terms.post_tag.name',
'post_title',
];
return $arr;
}
//
public function ep_find_related_args($arr)
{
$arr['orderby'] = 'relevance';
return $arr;
}