Meilisearch PHP | Documentation

SearchResult
in package
implements Countable, IteratorAggregate

Table of Contents

Interfaces

Countable
IteratorAggregate

Properties

$estimatedTotalHits  : int|null
`estimatedTotalHits` is the attributes returned by the Meilisearch server and its value will not be modified by the methods in this class.
$facetDistribution  : array<string, mixed>
$facetStats  : array<string, mixed>
$hits  : array<int, array<string, mixed>>
$hitsCount  : int|null
$hitsPerPage  : int|null
$limit  : int|null
$numberedPagination  : bool
$offset  : int|null
$page  : int|null
$processingTimeMs  : int
$query  : string
$raw  : array<string, mixed>
$semanticHitCount  : int|null
$totalHits  : int|null
$totalPages  : int|null

Methods

__construct()  : mixed
applyOptions()  : self
Return a new {@see SearchResult} instance.
count()  : int
getEstimatedTotalHits()  : int
getFacetDistribution()  : array<string, mixed>
getFacetStats()  : array<string, mixed>
getHit()  : mixed
getHits()  : array<int, array<string|int, mixed>>
getHitsCount()  : int
getHitsPerPage()  : int|null
getIterator()  : ArrayIterator
getLimit()  : int
getOffset()  : int
getPage()  : int|null
getProcessingTimeMs()  : int
getQuery()  : string
getRaw()  : array<string, mixed>
Return the original search result.
getSemanticHitCount()  : int
getTotalHits()  : int|null
getTotalPages()  : int|null
toArray()  : array<string|int, mixed>
toJSON()  : string
transformFacetDistribution()  : self
transformHits()  : self

Properties

$estimatedTotalHits

`estimatedTotalHits` is the attributes returned by the Meilisearch server and its value will not be modified by the methods in this class.

private int|null $estimatedTotalHits

Please, use hitsCount if you want to know the real size of the hits array at any time.

$facetDistribution

private array<string, mixed> $facetDistribution

Methods

__construct()

public __construct(array<string|int, mixed> $body) : mixed
Parameters
$body : array<string|int, mixed>

applyOptions()

Return a new {@see SearchResult} instance.

public applyOptions(mixed $options) : self

The $options parameter is an array, and the following keys are accepted:

  • transformFacetDistribution (callable)
  • transformHits (callable)

The method does NOT trigger a new search.

Parameters
$options : mixed
Return values
self

getEstimatedTotalHits()

public getEstimatedTotalHits() : int
Return values
int

getFacetDistribution()

public getFacetDistribution() : array<string, mixed>
Return values
array<string, mixed>

getFacetStats()

public getFacetStats() : array<string, mixed>
Return values
array<string, mixed>

getHit()

public getHit(int $key[, mixed $default = null ]) : mixed
Parameters
$key : int
$default : mixed = null

getHits()

public getHits() : array<int, array<string|int, mixed>>
Return values
array<int, array<string|int, mixed>>

getHitsCount()

public getHitsCount() : int
Return values
int

getHitsPerPage()

public getHitsPerPage() : int|null
Return values
int|null

getIterator()

public getIterator() : ArrayIterator
Return values
ArrayIterator

getPage()

public getPage() : int|null
Return values
int|null

getProcessingTimeMs()

public getProcessingTimeMs() : int
Return values
int

getQuery()

public getQuery() : string
Return values
string

getRaw()

Return the original search result.

public getRaw() : array<string, mixed>
Return values
array<string, mixed>

getSemanticHitCount()

public getSemanticHitCount() : int
Return values
int

getTotalHits()

public getTotalHits() : int|null
Return values
int|null

getTotalPages()

public getTotalPages() : int|null
Return values
int|null

toArray()

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

transformFacetDistribution()

public transformFacetDistribution(callable $callback) : self
Parameters
$callback : callable
Return values
self

transformHits()

public transformHits(callable $callback) : self
Parameters
$callback : callable
Return values
self

On this page

Search results