Skip to content

Commit

Permalink
Issue #3490233 by mkalkbrenner: solr_date field type is not mapped an…
Browse files Browse the repository at this point in the history
…ymore with search_api 1.36
  • Loading branch information
mkalkbrenner committed Nov 27, 2024
1 parent 36d59f7 commit c575286
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"ext-json": "*",
"ext-simplexml": "*",
"composer-runtime-api": ">=2.0",
"drupal/search_api": "~1.36",
"drupal/search_api": "^1.37|1.x-dev",
"composer/semver": "^1.0|^3.0",
"consolidation/annotated-command": "^2.12|^4.1",
"maennchen/zipstream-php": "^2.2.1|^3.0.2",
Expand Down
14 changes: 14 additions & 0 deletions src/EventSubscriber/SearchApiSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Drupal\search_api_solr\EventSubscriber;

use Drupal\search_api\Event\MappingFieldTypesEvent;
use Drupal\search_api\Event\MappingViewsFieldHandlersEvent;
use Drupal\search_api\Event\MappingViewsHandlersEvent;
use Drupal\search_api\Event\SearchApiEvents;
Expand All @@ -12,6 +13,18 @@
*/
class SearchApiSubscriber implements EventSubscriberInterface {

/**
* Adds the mapping how to treat some Solr special fields in views.
*
* @param \Drupal\search_api\Event\MappingViewsFieldHandlersEvent $event
* The Search API event.
*/
public function onMappingFieldTypes(MappingFieldTypesEvent $event) {
$mapping = & $event->getFieldTypeMapping();

$mapping['solr_date'] = 'date';
}

/**
* Adds the mapping how to treat some Solr special fields in views.
*
Expand Down Expand Up @@ -59,6 +72,7 @@ public static function getSubscribedEvents(): array {
}

return [
SearchApiEvents::MAPPING_FIELD_TYPES => 'onMappingFieldTypes',
SearchApiEvents::MAPPING_VIEWS_FIELD_HANDLERS => 'onMappingViewsFieldHandlers',
SearchApiEvents::MAPPING_VIEWS_HANDLERS => 'onMappingViewsHandlers',
];
Expand Down
2 changes: 1 addition & 1 deletion src/Plugin/search_api/backend/SearchApiSolrBackend.php
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ public function supportsDataType($type) {
$built_in_support = [
'location',
'rpt',
'solr_date_range',
'solr_string_storage',
'solr_string_docvalues',
'solr_text_omit_norms',
Expand All @@ -780,7 +781,6 @@ public function supportsDataType($type) {
'solr_text_wstoken',
'solr_text_custom',
'solr_text_custom_omit_norms',
'solr_date_range',
];
if (in_array($type, $built_in_support)) {
return TRUE;
Expand Down

0 comments on commit c575286

Please sign in to comment.