Skip to content

Commit 820fd0e

Browse files
committed
Described disabling counting the results
1 parent 3bceac2 commit 820fd0e

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php declare(strict_types=1);
2+
3+
use Ibexa\Contracts\Core\Repository\Values\Content\LocationQuery;
4+
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
5+
6+
/** @var \Ibexa\Contracts\Core\Repository\SearchService $searchService */
7+
8+
// For location searches
9+
$locationQuery = new LocationQuery();
10+
$locationQuery->performCount = false;
11+
12+
$locationResult = $searchService->findLocations($locationQuery);
13+
14+
// For content searches
15+
$contentQuery = new Query();
16+
$contentQuery->performCount = false;
17+
18+
$contentResult = $searchService->findContent($contentQuery);

docs/search/search_api.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,17 @@ $output->writeln($result->getName());
6161
$query->limit = 100;
6262
```
6363

64+
#### Disable result count
65+
66+
By default, a search query also counts all matching results.
67+
If you don't need the total count, set `performCount` to `false` on `Query` or `LocationQuery` to improve performance, especially for large result sets.
68+
69+
``` php
70+
[[= include_code('code_samples/api/public_php_api/src/perform_count.php') =]]
71+
```
72+
73+
When `performCount` is set to `false`, `$result->totalCount` is `null`.
74+
6475
#### Search with `query` and `filter`
6576

6677
You can use two properties of the `Query` object to search for content: `query` and `filter`.

0 commit comments

Comments
 (0)