0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

eZ Publish 5.x 検索まわり

Posted at

コンテンツの検索


use eZ\Publish\API\Repository\Values\Content\Query;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;

// ...

$searchService = $this->getRepository()->getSearchService();

$query = new Query();

$query->criterion = new Criterion\LogicalAnd(
    $criterionArray
);

// array( new SortClause\ContentId() )
$query->sortClauses = $sortMethodsArray;

$query->limit = 20;
$query->offset = 0;

$searchService->findContent($query);

ロケーションの検索


use eZ\Publish\API\Repository\Values\Content\LocationQuery;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion;
use eZ\Publish\API\Repository\Values\Content\Query\Criterion\Location;

// ...

$searchService = $this->getRepository()->getSearchService();

$query = new LocationQuery();

        $query->criterion = new Criterion\LogicalAnd(
            array(
                new Location\ParentLocationId( 2 ),
                new Criterion\ContentTypeIdentifier( array( "folder", "blog", "landing_page" ) )
            )
        );

        $searchResult = $this->getRepository()
            ->getSearchService()
            ->findLocations( $query );

Criterion Operators

Criterion\Operator::BETWEEN; // Criterion\Operator::BETWEEN, array( 1033920275, 1033920794 )
Criterion\Operator::EQ; // Criterion\Operator::EQ, 'Members'
Criterion\Operator::GT; // Criterion\Operator::GT,1343140540
Criterion\Operator::GTE;
Criterion\Operator::IN; // Operator::IN, array( 10, 14 )
Criterion\Operator::LIKE; // '*ezpublish*'
Criterion\Operator::LT;
Criterion\Operator::LTE;

Logical Criterions

Criterion\LogicalAnd;
Criterion\LogicalNot;
Criterion\LogicalOr;

Search Criterions

new Criterion\DateMetadata(
    Criterion\DateMetadata::MODIFIED,
    Criterion\Operator::BETWEEN,
    array( 1033920275, 1033920794 )
);

new Criterion\ContentTypeIdentifier( array( 'article', 'folder' ) );

new Criterion\LocationId( array( 1, 2, 5 ) );

new Criterion\Subtree( "/1/2/" );

new Criterion\SectionId( array( 2 ) );

new Criterion\ParentLocationId(  array( 1 ) );

new Criterion\UserMetadata(
    Criterion\UserMetadata::CREATOR,
    Operator::IN,
    array( 10, 14 )
);
Criterion\UserMetadata::CREATOR;
Criterion\UserMetadata::GROUP;
Criterion\UserMetadata::MODIFIER;
Criterion\UserMetadata::OWNER;

new Criterion\Visibility( Criterion\Visibility::VISIBLE );
Criterion\Visibility::VISIBLE;
Criterion\Visibility::HIDDEN;

new Criterion\ContentId(array( 1, 4, 10 ));

new Criterion\ContentTypeId( 4 );

new Criterion\ContentTypeGroupId( 2 );

new Criterion\DateMetadata(
    Criterion\DateMetadata::MODIFIED,
    Criterion\Operator::GT,
    1343140540
);

new Criterion\FullText( 'Contact*' );

new Criterion\Field( 'name', Criterion\Operator::EQ, 'Members' );

new Criterion\Status( array( Criterion\Status::STATUS_PUBLISHED ) );

new Criterion\LocationRemoteId(
    array(
        '3f6d92f8044aed134f32153517850f5a',
        'f3e90596361e31d496d4026eb624c983'
    )
);


Location\Depth( $operator, $value );
Location\Id( $value );
Location\IsMainLocation( IsMainLocation::MAIN|IsMainLocation::NOT_MAIN );
Location\ParentLocationId( int|int[] );
Location\Priority( $operator, $value );
Location\RemoteId( $value );
Location\SubTree( string|string[] );
Location\Visibility( Visibility::VISIBLE|Visibility::HIDDEN );

ソート句 (Sort Clauses)

new SortClause\Field('blog_post', 'publication_date', Query::SORT_DESC);
new SortClause\ContentId();
new SortClause\LocationPathString( Query::SORT_DESC );
new SortClause\LocationDepth( Query::SORT_ASC );
new SortClause\ContentName( Query::SORT_ASC );
new SortClause\LocationPriority( Query::SORT_DESC );
new SortClause\DatePublished();
new SortClause\DateModified();
new SortClause\SectionIdentifier();
new SortClause\SectionName();
new SortClause\ContentName();
new SortClause\Field( "folder", "name" );
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?