apply_filters( 'relevanssi_optimize_excerpts', bool $optimize )
Controls whether excerpt-building is optimized or done thoroughly.
true, prefer speed instead of quality when building excerpts. Default:
If you have long posts, building excerpts can slow down searching a lot. This filter hook can be used to make the excerpt-building faster, with the cost of possibly missing good excerpts.
When using word-based excerpts, the optimization means Relevanssi will create 50 first possible excerpts from the post, and will stop there. This means that if your excerpt length is 30 words, this won’t have effect unless the post is more than 1500 words.
When using character-based excerpts (but just don’t, word-based excerpts are much more efficient), optimization means Relevanssi will find ten possible excerpt candidates and will stop there.
Enabling the optimization is simple. Just add this to your theme
add_filter( 'relevanssi_optimize_excerpts', '__return_true' );
However, this is generally not necessary anymore. Relevanssi Premium 2.14.0 and free 4.12.0 introduced a new method of word-based excerpt-generation where Relevanssi will try to create 200 excerpts, spreading out the candidates all across the post instead of looking just at the beginning of the post.
This means this method of optimization is no longer usually necessary, and if further optimization is required, it’s better to use the
relevanssi_excerpt_gap filter hook.