- As I see, the plugin js file is not loaded on this page. Please tell me – are you using any caching or assets optimization plugins?
- Well, the plugin doesn’t look at the position of words when calculating each search result’s relevance score. But you can try to use the following code snippet:
class AWS_First_title_word {
public $terms = array();
public function __construct() {
add_filter( 'aws_indexed_data', array( $this, 'aws_indexed_data' ), 10, 2 );
add_filter( 'aws_search_terms', array( $this, 'aws_search_terms' ), 10, 2 );
add_filter( 'aws_search_query_array', array( $this, 'aws_search_query_array' ) );
}
function aws_indexed_data( $data, $id ) {
$data['terms']['full_title'][get_the_title( $id )] = 1;
return $data;
}
function aws_search_terms( $terms ) {
$this->terms = $terms;
return $terms;
}
function aws_search_query_array( $query ) {
$relevance = '';
if ( $this->terms ) {
foreach( $this->terms as $term ) {
$relevance .= "( case when ( term_source = 'full_title' AND term LIKE '{$term}%' ) then 800 else 0 end ) + ";
}
$query['relevance'] = preg_replace( '/\(SUM\([\s\S]*?\([\s\S]*?case[\s\S]*?end[\s\S]*?\)[\s\S]*?\+/i', '$0' . $relevance, $query['relevance'] );
}
return $query;
}
}
new AWS_First_title_word();
You need to add it somewhere outside the plugins folder. For example, inside functions.php file of your theme or use some plugin for adding code snippets.
Also, after adding this code, you need to re-index the plugin table.
3. Yes, I think the problem is in your theme template for products search results.