php8.5
Home/ Manual/ solr / solrdismaxquery/ SolrDisMaxQuery::removeBoostQuery

SolrDisMaxQuery::removeBoostQuery

PHP function Edit on GitHub ✎

Removes a boost query partial by field name (bq)

Description

SolrDisMaxQuery::removeBoostQuery(string $field): SolrDisMaxQuery

Removes a boost query partial from the existing query, only if SolrDisMaxQuery::addBoostQuery was used.

Parameters

field

Field Name

Return Values

SolrDisMaxQuery

Examples

SolrDisMaxQuery::removeBoostQuery() example

php
<?php

$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
    ->addBoostQuery('cat', 'electronics', 5.1)
    ->addBoostQuery('cat', 'hard drive')
;
echo $dismaxQuery.PHP_EOL;
// now remove a query part with field 'cat'
$dismaxQuery
->removeBoostQuery('cat');
echo $dismaxQuery . PHP_EOL;

?>

The above example will output something similar to:

output
q=lucene&defType=edismax&bq=cat:electronics^5.1 cat:hard drive
q=lucene&defType=edismax&bq=cat:hard drive

See Also

  • SolrDisMaxQuery::addBoostQuery
  • SolrDisMaxQuery::setBoostQuery

Source: reference/solr/solrdismaxquery/removeboostquery.xml · from the official PHP manual (php/doc-en)