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

SolrDisMaxQuery::addBoostQuery

PHP function Edit on GitHub ✎

Adds a boost query field with value and optional boost (bq parameter)

Description

SolrDisMaxQuery::addBoostQuery(string $field, string $value, [string $boost]): SolrDisMaxQuery

Adds a Boost Query field with value [and boost] (bq parameter)

Parameters

field
value
boost

Return Values

SolrDisMaxQuery

Examples

SolrDisMaxQuery::addBoostQuery() example

php
<?php

$dismaxQuery = new SolrDisMaxQuery("lucene");
$dismaxQuery
    ->addBoostQuery('cat', 'clothing', 2)
    ->addBoostQuery('cat', 'electronics', 5.1)
;
echo $dismaxQuery.PHP_EOL;
?>

The above example will output something similar to:

output
q=lucene&defType=edismax&bq=cat:clothing^2 cat:electronics^5.1

See Also

  • SolrDisMaxQuery::removeBoostQuery
  • SolrDisMaxQuery::setBoostQuery

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