Skip to main content

I do it like this: First

 function HOOK_search_api_alter_callback_info() { $callbacks['search_api_alter_add_keywords_field'] = array( 'name' => t('Keywords field from metatag module'), 'description' => t("Adds Keyword field from metatag module to indexed data."), 'class' => 'SearchApiAddKeywordField', ); return $callbacks; } 

Second

class SearchApiAddKeywordField extends SearchApiAbstractAlterCallback { public function alterItems(array &$items) { foreach ($items as $id => &$item) { if (!isset($item->metatags[$item->language]['keywords']['value'])) { $item->search_api_keyword = NULL; continue; } $item->search_api_keyword = strtolower ($item->metatags[$item->language]['keywords']['value']); } } public function propertyInfo() { return array( 'search_api_keyword' => array( 'label' => t('Keyword field'), 'description' => t('Add keyword field to index.'), 'type' => 'text', ), ); } } 

After Clear cache go to you index filters and check: Keywords field from metatag module

If Boost settings need to be changed (to give more importance to the field) do it now.

Index Again

Go to the search results view - the view you created to list indexed content.

Assuming that you have fulltext search filter in "Searched fields" select the new "field" Keyword field

Test the things out.

  • After Clear cache go to you index filters and check: Keywords field from metatag module
  • If Boost settings need to be changed (to give more importance to the field) do it now.
  • Index Again
  • Go to the search results view - the view you created to list indexed content.
  • Assuming that you have fulltext search filter in "Searched fields" select the new "field" Keyword field
  • Test the things out.

I do it like this: First

 function HOOK_search_api_alter_callback_info() { $callbacks['search_api_alter_add_keywords_field'] = array( 'name' => t('Keywords field from metatag module'), 'description' => t("Adds Keyword field from metatag module to indexed data."), 'class' => 'SearchApiAddKeywordField', ); return $callbacks; } 

Second

class SearchApiAddKeywordField extends SearchApiAbstractAlterCallback { public function alterItems(array &$items) { foreach ($items as $id => &$item) { if (!isset($item->metatags[$item->language]['keywords']['value'])) { $item->search_api_keyword = NULL; continue; } $item->search_api_keyword = strtolower ($item->metatags[$item->language]['keywords']['value']); } } public function propertyInfo() { return array( 'search_api_keyword' => array( 'label' => t('Keyword field'), 'description' => t('Add keyword field to index.'), 'type' => 'text', ), ); } } 

After Clear cache go to you index filters and check: Keywords field from metatag module

If Boost settings need to be changed (to give more importance to the field) do it now.

Index Again

Go to the search results view - the view you created to list indexed content.

Assuming that you have fulltext search filter in "Searched fields" select the new "field" Keyword field

Test the things out.

I do it like this: First

 function HOOK_search_api_alter_callback_info() { $callbacks['search_api_alter_add_keywords_field'] = array( 'name' => t('Keywords field from metatag module'), 'description' => t("Adds Keyword field from metatag module to indexed data."), 'class' => 'SearchApiAddKeywordField', ); return $callbacks; } 

Second

class SearchApiAddKeywordField extends SearchApiAbstractAlterCallback { public function alterItems(array &$items) { foreach ($items as $id => &$item) { if (!isset($item->metatags[$item->language]['keywords']['value'])) { $item->search_api_keyword = NULL; continue; } $item->search_api_keyword = strtolower ($item->metatags[$item->language]['keywords']['value']); } } public function propertyInfo() { return array( 'search_api_keyword' => array( 'label' => t('Keyword field'), 'description' => t('Add keyword field to index.'), 'type' => 'text', ), ); } } 
  • After Clear cache go to you index filters and check: Keywords field from metatag module
  • If Boost settings need to be changed (to give more importance to the field) do it now.
  • Index Again
  • Go to the search results view - the view you created to list indexed content.
  • Assuming that you have fulltext search filter in "Searched fields" select the new "field" Keyword field
  • Test the things out.
Source Link

I do it like this: First

 function HOOK_search_api_alter_callback_info() { $callbacks['search_api_alter_add_keywords_field'] = array( 'name' => t('Keywords field from metatag module'), 'description' => t("Adds Keyword field from metatag module to indexed data."), 'class' => 'SearchApiAddKeywordField', ); return $callbacks; } 

Second

class SearchApiAddKeywordField extends SearchApiAbstractAlterCallback { public function alterItems(array &$items) { foreach ($items as $id => &$item) { if (!isset($item->metatags[$item->language]['keywords']['value'])) { $item->search_api_keyword = NULL; continue; } $item->search_api_keyword = strtolower ($item->metatags[$item->language]['keywords']['value']); } } public function propertyInfo() { return array( 'search_api_keyword' => array( 'label' => t('Keyword field'), 'description' => t('Add keyword field to index.'), 'type' => 'text', ), ); } } 

After Clear cache go to you index filters and check: Keywords field from metatag module

If Boost settings need to be changed (to give more importance to the field) do it now.

Index Again

Go to the search results view - the view you created to list indexed content.

Assuming that you have fulltext search filter in "Searched fields" select the new "field" Keyword field

Test the things out.