diff --git a/metsis/metsis_search/config/install/views.view.metsis_search.yml b/metsis/metsis_search/config/install/views.view.metsis_search.yml index 1e6e50a..7a38092 100644 --- a/metsis/metsis_search/config/install/views.view.metsis_search.yml +++ b/metsis/metsis_search/config/install/views.view.metsis_search.yml @@ -2667,7 +2667,7 @@ display: group_type: group admin_label: 'Start date' plugin_id: search_api_date - operator: '<=' + operator: '>=' value: min: '' max: '' @@ -2718,7 +2718,7 @@ display: group_type: group admin_label: 'End date' plugin_id: search_api_date - operator: '>=' + operator: '<=' value: min: '' max: '' diff --git a/metsis/metsis_search/src/EventSubscriber/MetsisSearchEventSubscriber.php b/metsis/metsis_search/src/EventSubscriber/MetsisSearchEventSubscriber.php index 86ad893..7d8e86c 100644 --- a/metsis/metsis_search/src/EventSubscriber/MetsisSearchEventSubscriber.php +++ b/metsis/metsis_search/src/EventSubscriber/MetsisSearchEventSubscriber.php @@ -411,13 +411,13 @@ public function onPreQuery(PreQueryEvent $event) { if ($date_filter === 'STARTEND') { $start = $matches[0][0]; $end = $matches[0][1]; - $new_fq = $fq . ' OR (temporal_extent_start_date:[' . $start . ' TO *] AND temporal_extent_end_date:[* TO ' . $end . ']) OR (*:* -temporal_extent_end_date:*)'; + $new_fq = $fq . ' OR (temporal_extent_start_date:[* TO ' . $start . '] AND temporal_extent_end_date:[' . $end . ' TO *]) OR (*:* -temporal_extent_end_date:*)'; // dpm($new_fq); $filters['filters_2']->setQuery($new_fq); } // Else { - // $rep_str = $matches[0]; - // unset($filters['filters_2']); + // $rep_str = $matches[0]; + // unset($filters['filters_2']); // }. $solarium_query->setFilterQueries($filters); $solarium_query->addParam('end_date_query', $matches[0]); @@ -510,50 +510,50 @@ public function postCreateRequest(PostCreateRequest $event) { /* Rewrite the query if we got an end date filter. */ // $end_date_query = $req->getParam('end_date_query'); // if (NULL != $end_date_query) { - // $qs = '('; - // $query = $req->getParam('q'); - // $trim_query = rtrim($query, ')'); - // $okeys = $req->getParam('okeys'); - // $conjuction = ''; - // if (NULL != $okeys) { - // if (array_key_exists('#conjunction', $okeys)) { - // if ($okeys['#conjunction'] === 'AND') { - // $qs = '+('; - // $conjuction = 'AND'; - // } - // if ($okeys['#conjunction'] === 'OR') { - // $qs = '('; - // $conjuction = 'OR'; - // } - // unset($okeys['#conjunction']); - // } + // $qs = '('; + // $query = $req->getParam('q'); + // $trim_query = rtrim($query, ')'); + // $okeys = $req->getParam('okeys'); + // $conjuction = ''; + // if (NULL != $okeys) { + // if (array_key_exists('#conjunction', $okeys)) { + // if ($okeys['#conjunction'] === 'AND') { + // $qs = '+('; + // $conjuction = 'AND'; + // } + // if ($okeys['#conjunction'] === 'OR') { + // $qs = '('; + // $conjuction = 'OR'; + // } + // unset($okeys['#conjunction']); + // } // Foreach ($okeys as $k) { - // if ($conjuction === 'AND') { - // $qs .= '+full_text:"' . $k . '" '; - // } - // if ($conjuction === 'OR') { - // $qs .= 'full_text:"' . $k . '" '; - // } - // }. + // if ($conjuction === 'AND') { + // $qs .= '+full_text:"' . $k . '" '; + // } + // if ($conjuction === 'OR') { + // $qs .= 'full_text:"' . $k . '" '; + // } + // }. // $dkeys = explode(' ', $okeys); - // if (count($okeys) > 1) { - // $new_query = $trim_query . ' AND ' . $end_date_query . ') OR ' . $qs . $this->openEndDateQuery . ')'; - // } - // else { - // $new_query = '(' . $trim_query . ' AND ' . $end_date_query . ') OR ' . $qs . $this->openEndDateQuery . ')'; - // } - // $req->addParam('q', $new_query, TRUE); + // if (count($okeys) > 1) { + // $new_query = $trim_query . ' AND ' . $end_date_query . ') OR ' . $qs . $this->openEndDateQuery . ')'; + // } + // else { + // $new_query = '(' . $trim_query . ' AND ' . $end_date_query . ') OR ' . $qs . $this->openEndDateQuery . ')'; + // } + // $req->addParam('q', $new_query, TRUE); // $req->removeParam('okeys'); - // } - // if (NULL == $okeys) { - // $new_query = '(' . $trim_query . ' AND ' . $end_date_query . ') OR ' . '(*:* ' . $this->openEndDateQuery . ')'; - // $req->addParam('q', $new_query, TRUE); - // } - // $req->removeParam('end_date_query'); - // // dpm($new_query); + // } + // if (NULL == $okeys) { + // $new_query = '(' . $trim_query . ' AND ' . $end_date_query . ') OR ' . '(*:* ' . $this->openEndDateQuery . ')'; + // $req->addParam('q', $new_query, TRUE); + // } + // $req->removeParam('end_date_query'); + // // dpm($new_query); // } // /** @var Solarium\QueryType\Select\Query $query*/ // $query = $event->getQuery();