BUG 0000 "Change on class.AppSolr search criteria" CHANGE
This commit is contained in:
@@ -1171,32 +1171,30 @@ class AppSolr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// validate phrase in case of date
|
// validate phrase in case of date
|
||||||
if (($searchText [1] == "[")) {
|
if (($searchText [1] == "["))
|
||||||
|
{
|
||||||
// validate date range format
|
// validate date range format
|
||||||
// use regular expresion to validate it [yyyy-mm-dd TO yyyy-mm-dd]
|
// use regular expresion to validate it [yyyy-mm-dd TO yyyy-mm-dd]
|
||||||
|
$result1 = strpos($searchText, '-');
|
||||||
|
if ($result1 !== false)
|
||||||
|
{
|
||||||
$reg = "/:\[(\d\d\d\d-\d\d-\d\d|\*)\sTO\s(\d\d\d\d-\d\d-\d\d|\*)\]/";
|
$reg = "/:\[(\d\d\d\d-\d\d-\d\d|\*)\sTO\s(\d\d\d\d-\d\d-\d\d|\*)\]/";
|
||||||
// convert date to utc
|
// convert date to utc
|
||||||
$matched = preg_match ($reg, $searchText, $matches);
|
$matched = preg_match ($reg, $searchText, $matches);
|
||||||
if ($matched == 1) {
|
if ($matched == 1)
|
||||||
|
{
|
||||||
// the date interval is valid
|
// the date interval is valid
|
||||||
// convert to SOlr format
|
// convert to SOlr format
|
||||||
$fromDateOriginal = $matches [1];
|
$fromDateOriginal = $matches [1];
|
||||||
$fromDate = $matches [1];
|
$fromDate = $matches [1];
|
||||||
|
|
||||||
$toDateOriginal = $matches [2];
|
$toDateOriginal = $matches [2];
|
||||||
$toDate = $matches [2];
|
$toDate = $matches [2];
|
||||||
|
if ($fromDateOriginal != '*')
|
||||||
if ($fromDateOriginal != '*') {
|
{
|
||||||
// TODO complete date creation
|
|
||||||
// list($year, $month, $day) = sscanf($fromDateOriginal,
|
|
||||||
// '%04d/%02d/%02d');
|
|
||||||
// $fromDateDatetime = new DateTime($fromDateOriginal);
|
|
||||||
// $fromDateDatetime = date_create_from_format ( 'Y-m-d',
|
|
||||||
// $fromDateOriginal );
|
|
||||||
// $fromDateDatetime->getTimestamp ()
|
|
||||||
$fromDate = gmdate ("Y-m-d\T00:00:00\Z", strtotime ($fromDateOriginal));
|
$fromDate = gmdate ("Y-m-d\T00:00:00\Z", strtotime ($fromDateOriginal));
|
||||||
}
|
}
|
||||||
if ($toDateOriginal != '*') {
|
if ($toDateOriginal != '*')
|
||||||
|
{
|
||||||
// list($year, $month, $day) = sscanf($fromDateOriginal,
|
// list($year, $month, $day) = sscanf($fromDateOriginal,
|
||||||
// '%04d/%02d/%02d');
|
// '%04d/%02d/%02d');
|
||||||
// $toDateDatetime = new DateTime($toDateOriginal);
|
// $toDateDatetime = new DateTime($toDateOriginal);
|
||||||
@@ -1206,8 +1204,6 @@ class AppSolr
|
|||||||
}
|
}
|
||||||
$searchText = ":[" . $fromDate . " TO " . $toDate . "]";
|
$searchText = ":[" . $fromDate . " TO " . $toDate . "]";
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
throw new InvalidIndexSearchTextException ("Invalid search text. Expected date interval format => {variable_name}:[YYYY-MM-DD TO YYYY-MM-DD]");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1223,7 +1219,8 @@ class AppSolr
|
|||||||
$v3 = str_replace( '<','' ,':[* TO '.$v2.']' );
|
$v3 = str_replace( '<','' ,':[* TO '.$v2.']' );
|
||||||
$searchText = $v3;
|
$searchText = $v3;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$v1 = str_replace( '<', '', $searchText );
|
$v1 = str_replace( '<', '', $searchText );
|
||||||
$v2 = str_replace( ':', '', $v1);
|
$v2 = str_replace( ':', '', $v1);
|
||||||
$v3 = (int) $v2-1;
|
$v3 = (int) $v2-1;
|
||||||
@@ -1243,7 +1240,8 @@ class AppSolr
|
|||||||
$v3 = str_replace( '>','' ,':['.$v2.' TO *]' );
|
$v3 = str_replace( '>','' ,':['.$v2.' TO *]' );
|
||||||
$searchText = $v3;
|
$searchText = $v3;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
$v1 = str_replace( '>', '', $searchText );
|
$v1 = str_replace( '>', '', $searchText );
|
||||||
$v2 = str_replace( ':', '', $v1 );
|
$v2 = str_replace( ':', '', $v1 );
|
||||||
$v3 = (int) $v2+1;
|
$v3 = (int) $v2+1;
|
||||||
@@ -1251,16 +1249,6 @@ class AppSolr
|
|||||||
$searchText = $v4;
|
$searchText = $v4;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// validate phrase in case of |
|
|
||||||
$result2 = strpos($searchText, '|');
|
|
||||||
if($result2 !== false)
|
|
||||||
{
|
|
||||||
$v1 = str_replace( '|', ' TO ', $searchText );
|
|
||||||
$v2 = str_replace( ':', '', $v1 );
|
|
||||||
$v3 = str_replace( '','' ,':['.$v2.']' );
|
|
||||||
$searchText = $v3;
|
|
||||||
}
|
|
||||||
|
|
||||||
$formattedSearchText .= $indexFieldName . $searchText;
|
$formattedSearchText .= $indexFieldName . $searchText;
|
||||||
$includeToken = true;
|
$includeToken = true;
|
||||||
}
|
}
|
||||||
@@ -3063,19 +3051,17 @@ class AppSolr
|
|||||||
|
|
||||||
for ($skip = $SkipRecords; $skip <= $numRows;) {
|
for ($skip = $SkipRecords; $skip <= $numRows;) {
|
||||||
$aaAPPUIds = $this->getPagedApplicationUids ($skip, $trunk);
|
$aaAPPUIds = $this->getPagedApplicationUids ($skip, $trunk);
|
||||||
|
|
||||||
printf ("Indexing %d to %d \n", $skip, $skip + $trunk);
|
printf ("Indexing %d to %d \n", $skip, $skip + $trunk);
|
||||||
$initTimeDoc = microtime (true);
|
$initTimeDoc = microtime (true);
|
||||||
$this->updateApplicationSearchIndex ($aaAPPUIds, false);
|
$this->updateApplicationSearchIndex ($aaAPPUIds, false);
|
||||||
|
|
||||||
$curTimeDoc = gmdate ('H:i:s', (microtime (true) - $initTimeDoc));
|
$curTimeDoc = gmdate ('H:i:s', (microtime (true) - $initTimeDoc));
|
||||||
printf ("Indexing document time: %s \n", $curTimeDoc);
|
printf ("Indexing document time: %s \n", $curTimeDoc);
|
||||||
$skip += $trunk;
|
$skip += $trunk;
|
||||||
}
|
}
|
||||||
|
|
||||||
$curTimeDoc = gmdate ('H:i:s', (microtime (true) - $initTimeAll));
|
$curTimeDoc = gmdate ('H:i:s', (microtime (true) - $initTimeAll));
|
||||||
printf ("Total reindex time: %s \n", $curTimeDoc);
|
printf ("Total reindex time: %s \n", $curTimeDoc);
|
||||||
printf ("Reindex completed successfully!!.\n");
|
printf ("Reindex completed successfully!!.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user