...
Code Block | ||
---|---|---|
| ||
$result = $searchService->findContent( $query ); $output->writeln( 'Found ' . $result->totalCount . ' items' ); foreach ( $result->searchHits as $searchHit ) { $output->writeln( $searchHit->valueObject->contentInfo->name ); } |
The The searchHits
properties properties of the the SearchResult
object object is an array of ContentInfo
objects SearchHit objects. In valueObject
property of SearchHit
, you will find the Content
object that match the given given Query
.
Tip: If you you are searching using a unique identifier, for instance using the content id or content remote id criterion, then you can use SearchService::findSingle()
, this takes a Criterion and returns a single Content, or throws NotFound exception if none is found.
...