repatched for custom dynmaic field definition : https://drupal.org/node/1846860#comment-7805861

This commit is contained in:
Bachir Soussi Chiadmi
2013-09-26 16:46:14 +02:00
parent d8237ffb99
commit 62b7436183
4 changed files with 217 additions and 107 deletions

View File

@@ -26,28 +26,6 @@ class SearchApiSolrService extends SearchApiAbstractService {
*/
protected $solr;
/**
* An array of all recognized types.
*
* Maps the type names to the prefixes used for identifying them in the Solr
* schema.
*
* @var array
*/
protected static $type_prefixes = array(
'text' => 'tm',
'tokens' => 'tm',
'string' => 's',
'integer' => 'i',
'decimal' => 'f',
'date' => 'd',
'duration' => 'i',
'boolean' => 'b',
'uri' => 's',
'location' => 'loc',
'geohash' => 'geo',
);
/**
* Static cache for getFieldNames().
*
@@ -290,7 +268,8 @@ class SearchApiSolrService extends SearchApiAbstractService {
* Overrides SearchApiAbstractService::supportsFeature().
*/
public function supportsFeature($feature) {
$supported = drupal_map_assoc(array(
// Search API features.
$supported = array(
'search_api_autocomplete',
'search_api_facets',
'search_api_facets_operator_or',
@@ -300,7 +279,14 @@ class SearchApiSolrService extends SearchApiAbstractService {
'search_api_spellcheck',
'search_api_data_type_location',
'search_api_data_type_geohash',
));
);
// Custom data types.
foreach (search_api_solr_get_dynamic_field_info() as $type => $info) {
$supported[] = 'search_api_data_type_' . $type;
}
$supported = drupal_map_assoc($supported);
return isset($supported[$feature]);
}
@@ -495,8 +481,9 @@ class SearchApiSolrService extends SearchApiAbstractService {
}
$inner_type = search_api_extract_inner_type($type);
$pref = isset(self::$type_prefixes[$inner_type]) ? self::$type_prefixes[$inner_type] : '';
if ($pref != 'tm') {
$type_info = search_api_solr_get_dynamic_field_info($inner_type);
$pref = isset($type_info['prefix']) ? $type_info['prefix']: '';
if (empty($type_info['always multiValued'])) {
$pref .= $type == $inner_type ? 's' : 'm';
}
if (!empty($this->options['clean_ids'])) {