SolrClient::deleteByQuery

(PECL solr >= 0.9.2)
Deletes all documents matching the given query
public SolrUpdateResponse SolrClient::deleteByQuery ( string $query )

Deletes all documents matching the given query.

Parameters:
query

The query

Returns:

Returns a SolrUpdateResponse on success and throws an exception on failure.

Exception:

Throws SolrClientException if the client had failed, or there was a connection issue.

Throws SolrServerException if the Solr Server had failed to process the request.

Examples:
SolrQuery::deleteByQuery() example
<?php

$options = array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
);

$client = new SolrClient($options);

//This will erase the entire index
$client->deleteByQuery("*:*");
$client->commit();

?>

See also:

SolrClient::deleteById() -

SolrClient::deleteByIds() -

SolrClient::deleteByQueries() -

doc_php
2016-02-24 16:10:55
Comments
Leave a Comment

Please login to continue.