Title: Custom Post Types &amp; Custom Fields
Last modified: August 30, 2016

---

# Custom Post Types & Custom Fields

 *  Resolved [JoeLyons23](https://wordpress.org/support/users/joelyons23/)
 * (@joelyons23)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-custom-fields-1/)
 * Everything is installed and working from what I can tell. With this plugin and
   elasticsearch I have been able to expand my search results to include a Custom
   Post Type Title, however the search is not returning any results from a custom
   field (multi-line text) associated with this CPT. Is there a way to add this 
   custom field to be indexed by elasticsearch?
 * [https://wordpress.org/plugins/elasticsearch-indexer/](https://wordpress.org/plugins/elasticsearch-indexer/)

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [wallmanderco](https://wordpress.org/support/users/wallmanderco/)
 * (@wallmanderco)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-custom-fields-1/#post-6424132)
 * 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](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. 🙂
 *  Thread Starter [JoeLyons23](https://wordpress.org/support/users/joelyons23/)
 * (@joelyons23)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-custom-fields-1/#post-6424198)
 * 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),
                               ],
                           ],
                       ],
                   ],
               ]);
           }
       ```
   
 *  Plugin Author [wallmanderco](https://wordpress.org/support/users/wallmanderco/)
 * (@wallmanderco)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-custom-fields-1/#post-6424307)
 * 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');
       ```
   
 *  Plugin Author [wallmanderco](https://wordpress.org/support/users/wallmanderco/)
 * (@wallmanderco)
 * [10 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-custom-fields-1/#post-6424431)
 * I’ll close this due to lack of response.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Custom Post Types & Custom Fields’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/elasticsearch-indexer_acd3f1.svg)
 * [Elasticsearch Indexer](https://wordpress.org/plugins/elasticsearch-indexer/)
 * [Support Threads](https://wordpress.org/support/plugin/elasticsearch-indexer/)
 * [Active Topics](https://wordpress.org/support/plugin/elasticsearch-indexer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/elasticsearch-indexer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/elasticsearch-indexer/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [wallmanderco](https://wordpress.org/support/users/wallmanderco/)
 * Last activity: [10 years, 11 months ago](https://wordpress.org/support/topic/custom-post-types-custom-fields-1/#post-6424431)
 * Status: resolved