for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
/*
* This file is part of Solr Client Symfony package.
*
* (c) ingatlan.com Zrt. <[email protected]>
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace iCom\SolrClient\Query\Command;
use iCom\SolrClient\JsonHelper;
use iCom\SolrClient\Query\Command;
/**
* @see https://lucene.apache.org/solr/guide/8_3/uploading-data-with-index-handlers.html#commit-and-optimize-during-updates
* @psalm-immutable
final class Commit implements Command
{
use JsonHelper;
* @psalm-var array{waitSearcher: ?bool, expungeDeletes: ?bool}
private array $options = [
'waitSearcher' => null,
'expungeDeletes' => null,
];
* @psalm-pure
public static function create(): self
return new self();
}
public function enableWaitSearcher(): self
$commit = clone $this;
$commit->options['waitSearcher'] = true;
return $commit;
public function disableWaitSearcher(): self
$commit->options['waitSearcher'] = false;
public function enableExpungeDeletes(): self
$commit->options['expungeDeletes'] = true;
public function disableExpungeDeletes(): self
$commit->options['expungeDeletes'] = false;
public function toJson(): string
return self::jsonEncode(array_filter($this->options, static function ($option): bool { return null !== $option; }), JSON_FORCE_OBJECT);
public function getName(): string
return 'commit';