Add fields to a search index
Last updated on
2 July 2019
This is documentation for Drupal 7, which is no longer supported. Learn more and find resources for Drupal 7 sites
$index = search_api_index_load('person-index', TRUE);
$fields = array(
'options' => $index->options,
);
$fields['options']['fields']['example_integer_field_name'] = array(
'type' => 'integer',
);
$fields['options']['fields']['example_text_field_name'] = array(
'type' => 'text',
);
search_api_index_edit($index->id, $fields); The array keys (like example_integer_field_name) are the property paths or machine names for the fields – e.g., author:name for the Author name. The valid types are returned by search_api_get_data_type_info(). Note, though, that for multi-valued fields you’ll have to use list<TYPE> instead (or even list<list<TYPE>> in case of two multi-valued properties in the property path – like field_tags:parent.)
Help improve this page
Page status: No known problems
You can:
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion