Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Description context – character depth and possibility of multiple contexts? › Reply To: Description context – character depth and possibility of multiple contexts?
Hi,
1. Very likely, but you should try it. The function used for that creates an array of words, then tries to match the closest ones. It is the best possible tested solution we could come up with, which works for longer strings (around 10000 characters).
So iterating through a bigger array of strings may lead to memory and processing issues.
2. I’m afraid not possible without custom coding. The internal function currently used only matches the first matching context, and then exits. The best possible approach to this would be to simply create a function, which can get a number of matching and non-overlapping contexts, then during the post process replace the result contents via the asp_results hook. Something like:
add_filter('asp_results', 'asp_my_custom_contexts', 10, 1);
function asp_my_custom_contexts($results) {
foreach ( $results as $k => &$r ) {
$p = get_post($r->id);
$r->content = my_magic_multiple_context_function($p->post_content);
}
return $results;
}
function my_magic_multiple_context_function($s) {
// Do the magic here
return "extracted contexts..";
}
This would work then after plugin updates too. Maybe there is a way to extraxt the method used by relevanssi from their source code to do this.