mirror of
https://github.com/Codappix/search_core.git
synced 2024-11-22 14:36:11 +01:00
FIX: Catch deletion of non existing documents
* Catch exception raised during deletion of documents that are not already indexed. * Log failed deletion tries. * Add new necessary Exceptions.
This commit is contained in:
parent
d358714d0d
commit
8448618f60
3 changed files with 60 additions and 6 deletions
25
Classes/Configuration/NoConfigurationException.php
Executable file
25
Classes/Configuration/NoConfigurationException.php
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
namespace Leonmrni\SearchCore\Configuration;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class NoConfigurationException extends \InvalidArgumentException
|
||||||
|
{
|
||||||
|
}
|
|
@ -92,12 +92,16 @@ class Elasticsearch implements Singleton, ConnectionInterface
|
||||||
|
|
||||||
public function deleteDocument($documentType, $identifier)
|
public function deleteDocument($documentType, $identifier)
|
||||||
{
|
{
|
||||||
$this->withType(
|
try {
|
||||||
$documentType,
|
$this->withType(
|
||||||
function ($type) use ($identifier) {
|
$documentType,
|
||||||
$type->deleteById($identifier);
|
function ($type) use ($identifier) {
|
||||||
}
|
$type->deleteById($identifier);
|
||||||
);
|
}
|
||||||
|
);
|
||||||
|
} catch (\Elastica\Exception\NotFoundException $exception) {
|
||||||
|
$this->logger->debug('Tried to delete document in index, which does not exist.', [$documentType, $identifier]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function updateDocument($documentType, array $document)
|
public function updateDocument($documentType, array $document)
|
||||||
|
|
25
Classes/Domain/Index/NoRecordFoundException.php
Executable file
25
Classes/Domain/Index/NoRecordFoundException.php
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
<?php
|
||||||
|
namespace Leonmrni\SearchCore\Domain\Index;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License
|
||||||
|
* as published by the Free Software Foundation; either version 2
|
||||||
|
* of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||||
|
* 02110-1301, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
class NoRecordFoundException extends IndexingException
|
||||||
|
{
|
||||||
|
}
|
Loading…
Reference in a new issue