The data is already indexed but not used in search. To add fields to be search take a look at this:
https://github.com/wallmanderco/elasticsearch-indexer/blob/master/src/Model/Query/WpConverter.php#L339-L368
There are 2 filters, esi_search_fields_multi_match and esi_search_fields_fuzzy.
Meta data is stored in meta_data.my_field_name.
You should be able to figure the rest out. If not then post here and I’ll assist you further.
If you solved it, then post here and let me know how it went. 🙂
Thanks for the quick response. The field name I am looking to include in the search is wpcf-synopsis
However when I include ‘meta_data.wpcf_synopsis’ to the filters, the results are not changing.
Here is the code… Am I missing something obvious here?
public static function argS(Query $query, $value, &$q)
{
$query->setQuery([
'bool' => [
'should' => [
[
'multi_match' => [
'fields' => apply_filters('esi_search_fields_multi_match', [
'post_title^10',
'terms.*.name^4',
'post_excerpt^2',
'meta_data.wpcf-synopsis' ,
'post_content',
]),
'query' => $value,
],
],
[
'fuzzy_like_this' => [
'fields' => apply_filters('esi_search_fields_fuzzy', [
'post_title',
'meta_data.wpcf-synopsis',
'post_excerpt',
]),
'like_text' => $value,
'min_similarity' => apply_filters('esi_min_similarity', 0.75),
],
],
],
],
]);
}
Sorry, my bad. Its post_meta and not meta_data.
Change that and it should work, however, you are not really sopose to edit the code in the plugin directly. Try adding this to your themes functions.php instead:
function addSynopsisToSearch($vars)
{
$vars[] = 'post_meta.wpcf-synopsis';
return $vars;
}
add_filter('esi_search_fields_multi_match', 'addSynopsisToSearch');
add_filter('esi_search_fields_fuzzy', 'addSynopsisToSearch');
I’ll close this due to lack of response.