Last active
August 29, 2015 14:25
-
-
Save sebas5384/98f652d25532428b74d0 to your computer and use it in GitHub Desktop.
Drupal: Fulltext with partial matching for Search API Solr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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