Skip to content

Commit b586e26

Browse files
committed
Added doc for TaxonomyNoEntries
1 parent c3b4388 commit b586e26

File tree

6 files changed

+64
-0
lines changed

6 files changed

+64
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Ibexa\Contracts\Core\Repository\Values\Content\Query;
6+
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier;
7+
use Ibexa\Contracts\Core\Repository\Values\Content\Query\Criterion\LogicalAnd;
8+
use Ibexa\Contracts\Taxonomy\Search\Query\Criterion\TaxonomyNoEntries;
9+
10+
$query = new Query();
11+
$query->query = new LogicalAnd([
12+
new TaxonomyNoEntries('tags'),
13+
new ContentTypeIdentifier('article'),
14+
]
15+
);
16+
17+
/** @var \Ibexa\Contracts\Core\Repository\SearchService $searchService */
18+
$results = $searchService->findContent($query);

docs/content_management/taxonomy/taxonomy_api.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,15 @@ and a `position` parameter, which is either `TaxonomyServiceInterface::MOVE_POSI
7171

7272
Taxonomy entry management functions triggers events you can listen to.
7373
For more information, see [Taxonomy events](taxonomy_events.md).
74+
75+
## Search
76+
77+
You can search for content based on its taxonomy entry assignments by using the standard
78+
[`SearchService`](search_api.md) with taxonomy-specific Search Criteria:
79+
80+
| Criterion | Description |
81+
|---|---|
82+
| [TaxonomyEntryId](taxonomy_entry_id.md) | Find content assigned to a specific taxonomy entry |
83+
| [TaxonomyNoEntries](taxonomy_no_entries.md) | Find content that has no entries assigned from a given taxonomy |
84+
85+
You can also use the [TaxonomyEntryId Aggregation](taxonomyentryid_aggregation.md) to count content items per taxonomy entry.

docs/search/criteria_reference/isfieldempty_criterion.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ The `IsFieldEmpty` Criterion isn't available in [Repository filtering](search_ap
1818

1919
The Richtext field type (`ezrichtext`) isn't searchable in the Legacy search engine.
2020

21+
The `IsFieldEmpty` criterion doesn't work for [Taxonomy entry assignment](taxonomyentryassignmentfield.md) fields.
22+
For this use case, use [`TaxonomyNoEntries`](taxonomy_no_entries.md) instead.
23+
2124
## Example
2225

2326
### PHP

docs/search/criteria_reference/search_criteria_reference.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ Due to this storage limitation, searching content using the Country field type o
6868
| [Sibling](sibling_criterion.md) | Locations that are children of the same parent | &#10004; | &#10004; | &#10004; | |
6969
| [Subtree](subtree_criterion.md) | Location subtree | &#10004; | &#10004; | &#10004; | |
7070
| [TaxonomyEntryId](taxonomy_entry_id.md) | Content tagged with Entry ID | &#10004; | &#10004; | &#10004; | |
71+
| [TaxonomyNoEntries](taxonomy_no_entries.md) | Content with no entries assigned from a given taxonomy | &#10004; | &#10004; | &#10004; | |
7172
| [UserEmail](useremail_criterion.md) | Email address of a User account | &#10004; | &#10004; | &#10004; | |
7273
| [UserId](userid_criterion.md) | User ID | &#10004; | &#10004; | &#10004; | |
7374
| [UserLogin](userlogin_criterion.md) | User login | &#10004; | &#10004; | &#10004; | |
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
description: TaxonomyNoEntries Search Criterion
3+
---
4+
5+
# TaxonomyNoEntries Criterion
6+
7+
The [`TaxonomyNoEntries` Search Criterion](https://example.com/api/php_api/php_api_reference/classes/Ibexa-Contracts-Taxonomy-Search-Query-Criterion-TaxonomyNoEntries.html) searches for content that has no entries assigned from the specified [taxonomy](taxonomy.md).
8+
9+
Use it when you need to find content items to which no taxonomy entries have been assigned (for example, articles without tags).
10+
It is available for all supported search engines and in [repository filtering](search_api.md#repository-filtering)
11+
12+
## Arguments
13+
14+
- `taxonomy` - `string` representing the identifier of the taxonomy (for example, `tags` or `categories`)
15+
16+
## Example
17+
18+
### PHP
19+
20+
The following example searches for articles that have no entries assigned in the `tags` taxonomy:
21+
22+
```php hl_lines="11-14"
23+
[[= include_file('code_samples/search/content/taxonomy_no_entries_criterion.php') =]]
24+
```
25+
26+
The criteria limit the results to content matching all of the conditions listed below:
27+
28+
- content has no entries assigned in the `tags` taxonomy
29+
- content type is `article`

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,7 @@ nav:
568568
- Sibling: search/criteria_reference/sibling_criterion.md
569569
- Subtree: search/criteria_reference/subtree_criterion.md
570570
- TaxonomyEntryID: search/criteria_reference/taxonomy_entry_id.md
571+
- TaxonomyNoEntries: search/criteria_reference/taxonomy_no_entries.md
571572
- UserEmail: search/criteria_reference/useremail_criterion.md
572573
- UserId: search/criteria_reference/userid_criterion.md
573574
- UserLogin: search/criteria_reference/userlogin_criterion.md

0 commit comments

Comments
 (0)