Skip to content

Commit

Permalink
Merge pull request #1201 from griidc/release/6.26.0
Browse files Browse the repository at this point in the history
Release/6.26.0
  • Loading branch information
mickel1138 authored Jun 24, 2022
2 parents 19b139a + e950bf3 commit bb47ff7
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 31 deletions.
4 changes: 4 additions & 0 deletions assets/js/vue/components/search/SearchForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,17 @@ export default {
onStartDateChanged(event) {
if (event.value instanceof Date) {
this.form.collectionStartDate = event.value.toLocaleDateString();
} else if (event.value) {
this.form.collectionStartDate = event.value;
} else {
this.form.collectionStartDate = '';
}
},
onEndDateChanged(event) {
if (event.value instanceof Date) {
this.form.collectionEndDate = event.value.toLocaleDateString();
} else if (event.value) {
this.form.collectionEndDate = event.value;
} else {
this.form.collectionEndDate = '';
}
Expand Down
30 changes: 15 additions & 15 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 15 additions & 16 deletions src/Util/Search.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ private function getFieldsQuery(string $queryTerm, string $specificField = null,
// Bool query to add all fields
$fieldsBoolQuery = new Query\BoolQuery();

$queryTerm = $this->doesDoiExistInQueryTerm($queryTerm, $fieldsBoolQuery);
$queryTerm = $this->doesUdiExistInQueryTerm($queryTerm, $fieldsBoolQuery);
$this->doesDoiExistInQueryTerm($queryTerm, $fieldsBoolQuery);
$this->doesUdiExistInQueryTerm($queryTerm, $fieldsBoolQuery);

$simpleQuery = new Query\SimpleQueryString($queryTerm, $specificField);
$simpleQuery->setParam('flags', 'PHRASE|PREFIX|WHITESPACE');
Expand Down Expand Up @@ -791,18 +791,17 @@ private function getCollectionEndDateQuery(array $collectionDates): Query\Range
* @param string $queryTerm Query term that needs to be checked if DOI exists.
* @param Query\BoolQuery $fieldsBoolQuery The fields elastic boolean query that DOI query is added to.
*
* @return string
* @return void
*/
private function doesDoiExistInQueryTerm(string $queryTerm, Query\BoolQuery $fieldsBoolQuery): string
private function doesDoiExistInQueryTerm(string $queryTerm, Query\BoolQuery $fieldsBoolQuery): void
{
$doiRegEx = '!\b(?:[Dd][Oo][Ii]\s*:\s*)?(10.\d{4,9}/[-._;()/:A-Z0-9a-z]+)\b!';
if (preg_match_all($doiRegEx, $queryTerm, $matches)) {
trim(preg_replace($doiRegEx, '', $queryTerm));
$queryTerm = $matches[1][0];
$fieldsBoolQuery->addShould($this->getDoiQuery($queryTerm));
$fieldsBoolQuery->addShould($this->getPubDoiQuery($queryTerm));
foreach ($matches[1] as $doi) {
$fieldsBoolQuery->addShould($this->getDoiQuery($doi));
$fieldsBoolQuery->addShould($this->getPubDoiQuery($doi));
}
}
return $queryTerm;
}

/**
Expand Down Expand Up @@ -863,19 +862,19 @@ private function getUdiQuery(string $queryTerm): Query\MatchPhrase
* @param string $queryTerm Query term that needs to be checked if udi exists.
* @param Query\BoolQuery $fieldsBoolQuery The fields elastic boolean query that udi query is added to.
*
* @return string
* @return void
*/
private function doesUdiExistInQueryTerm(string $queryTerm, Query\BoolQuery $fieldsBoolQuery): string
private function doesUdiExistInQueryTerm(string $queryTerm, Query\BoolQuery $fieldsBoolQuery): void
{
$udiRegEx = '/\b([A-Z\d]{2}\.x\d\d\d\.\d\d\d[:.]\d\d\d\d)\b/i';
if (preg_match_all($udiRegEx, $queryTerm, $matches)) {
trim(preg_replace($udiRegEx, '', $queryTerm));
$queryTerm = $matches[1][0];
// Replacing the 11th position to ":"
$queryTerm = substr_replace($queryTerm, ':', 11, 1);
$fieldsBoolQuery->addShould($this->getUdiQuery($queryTerm));
foreach ($matches[1] as $udi) {
// Replacing the 11th position to ":"
$udi = substr_replace($udi, ':', 11, 1);
$fieldsBoolQuery->addShould($this->getUdiQuery($udi));
}
}
return $queryTerm;
}

/**
Expand Down

0 comments on commit bb47ff7

Please sign in to comment.