SolrCollapseFunction::__construct

(PECL solr >= 2.2.0)
Constructor
public SolrCollapseFunction::__construct ([ string $field ] )

Collapse Function constructor

Parameters:
field

The field name to collapse on.

In order to collapse a result. The field type must be a single valued String, Int or Float.

Examples:
SolrCollapseFunction::__construct() example
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
 
include "bootstrap.php";
 
$options array
(
    'hostname' => SOLR_SERVER_HOSTNAME,
    'login'    => SOLR_SERVER_USERNAME,
    'password' => SOLR_SERVER_PASSWORD,
    'port'     => SOLR_SERVER_PORT,
    'path'     => SOLR_SERVER_PATH
);
 
$client new SolrClient($options);
 
$query new SolrQuery('*:*');
 
$func new SolrCollapseFunction('field_name');
 
$func->setMax('sum(cscore(),field(some_other_field))');
$func->setSize(100);
$func->setNullPolicy(SolrCollapseFunction::NULLPOLICY_EXPAND);
 
$query->collapse($func);
 
$queryResponse $client->query($query);
 
$response $queryResponse->getResponse();
 
print_r($response);
 
?>
See also:

SolrQuery::collapse() -

doc_php
2025-01-10 15:47:30
Comments
Leave a Comment

Please login to continue.