Message-ID: <457780760.3482.1485853361355.JavaMail.confluence@ip-10-127-227-164> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_3481_1573729494.1485853361355" ------=_Part_3481_1573729494.1485853361355 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html Criterion Independance example

Criterion Independance example

With eZ Publish you can have multiple location content. Criterions do not r= elate to others criterion you can  use the Public API and Criterion to= search this content, it can lead to a comportement you are not expecting.
Example of Criterions not relating to each other:
 
There is a Content with two Locations: Location A and Location B
 
Searching with LocationId criterion with Location B id and Visibility crite= rion with Visibility::VISIBLE will return the Content because conditions ar= e satisfied:
 
=20
<?php
=20
use eZ\Publish\API\Repository\Values\Content\Query;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\LogicalAnd;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\LocationId;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Visibility;
=20
/** @var string|int $locationBId */
/** @var \eZ\Publish\API\Repository\Repository $repository */

$searchService =3D $repository->getSearchService();
=20
$query =3D new Query(
    array(
        'filter' =3D> new LogicalAnd(
            array(
                new LocationId( $locationBId ),
                new Visibility( Visibility::VISIBLE ),
            )
        )
    )
);
=20
$searchResult =3D $searchService->findContent( $query );
=20
// Content is found
$content =3D $searchResult->searchHits[0];
=20
------=_Part_3481_1573729494.1485853361355--