Skip to content

Commit

Permalink
remove fq from delete-query
Browse files Browse the repository at this point in the history
  • Loading branch information
floriansemm committed Nov 14, 2016
1 parent 174dd8a commit 17acca4
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Client/Solarium/SolariumMulticoreClient.php
Expand Up @@ -3,6 +3,7 @@
namespace FS\SolrBundle\Client\Solarium;

use FS\SolrBundle\Doctrine\Mapper\MetaInformationInterface;
use FS\SolrBundle\Query\DeleteDocumentQuery;
use FS\SolrBundle\Query\FindByIdentifierQuery;
use Solarium\Core\Query\QueryInterface;
use Solarium\QueryType\Update\Query\Document\DocumentInterface;
Expand Down Expand Up @@ -48,7 +49,7 @@ public function delete(DocumentInterface $document, $index)
$documentFields = $document->getFields();
$documentKey = $documentFields[MetaInformationInterface::DOCUMENT_KEY_FIELD_NAME];

$deleteQuery = new FindByIdentifierQuery();
$deleteQuery = new DeleteDocumentQuery();
$deleteQuery->setDocument($document);
$deleteQuery->setDocumentKey($documentKey);

Expand Down
39 changes: 39 additions & 0 deletions Query/DeleteDocumentQuery.php
@@ -0,0 +1,39 @@
<?php

namespace FS\SolrBundle\Query;

use FS\SolrBundle\Query\Exception\QueryException;

class DeleteDocumentQuery extends AbstractQuery
{
/**
* @var string
*/
private $documentKey;

/**
* @param string $documentKey
*/
public function setDocumentKey($documentKey)
{
$this->documentKey = $documentKey;
}

/**
* @return string
*
* @throws QueryException when id or document_name is null
*/
public function getQuery()
{
$idField = $this->documentKey;

if ($idField == null) {
throw new QueryException('id should not be null');
}

$this->setQuery(sprintf('id:%s', $idField));

return parent::getQuery();
}
}

0 comments on commit 17acca4

Please sign in to comment.