Skip to content

Instantly share code, notes, and snippets.

@sebas5384
Last active August 29, 2015 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebas5384/98f652d25532428b74d0 to your computer and use it in GitHub Desktop.
Save sebas5384/98f652d25532428b74d0 to your computer and use it in GitHub Desktop.
Drupal: Fulltext with partial matching for Search API Solr
<?php
/**
* Provide Solr dynamic fields as Search API data types.
*
* This serves as a placeholder for documenting additional keys for
* hook_search_api_data_type_info() which are recognized by this module to
* automatically support dynamic field types from the schema.
*
* @return array
* In addition to the keys for the individual types that are defined by
* hook_search_api_data_type_info(), the following keys are regonized:
* - prefix: The Solr field name prefix to use for this type. Should match
* two existing dynamic fields definitions with names "{PREFIX}s_*" and
* "{PREFIX}m_*".
* - always multiValued: (optional) If TRUE, only the dynamic field name
* prefix (without the "_*" portion) with multiValued="true" should be given
* by "prefix", instead of the common prefix part for both the single-valued
* and the multi-valued field. This should be the case for all fulltext
* fields, since they might already be tokenized by the Search API. Defaults
* to FALSE.
*
* @see hook_search_api_data_type_info()
*/
function custom_search_search_api_data_type_info() {
return array(
// You can use any identifier you want here, but it makes sense to use the
// field type name from schema.xml.
'edge_n2_kw_text' => array(
// Stock hook_search_api_data_type_info() info:
'name' => t('Fulltext (w/ partial matching)'),
'fallback' => 'text',
// Dynamic field with name="te_*".
'prefix' => 'tem',
// Fulltext types should always be multi-valued.
'always multiValued' => TRUE,
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment