Hi,
I have the same issue as this post from 2017 https://forum.kaltura.org/t/playlist-order-by/4553 and it seems not resolved.
When I use KalturaMediaEntryOrderBy::PLAYS_ASC as a filter the entries are not returned in order. I tried in the API Console, and it doesn’t work well. It’s the code:
<?php
$filter = new KalturaMediaEntryFilter();
$filter->orderBy = KalturaMediaEntryOrderBy::PLAYS_ASC;
$pager = new KalturaFilterPager();
try {
$result = $client->media->listAction($filter, $pager);
var_dump($result);
} catch (Exception $e) {
echo $e->getMessage();
}
?>
But if I order with KalturaMediaEntryOrderBy::PLAYS_DESC it works well. It makes sense?
thanks
jess
February 9, 2021, 6:10pm
2
Thanks Jess,
As you said, it seems that the “plays” are deprecated from that entry media.list.
I share a code with esearch.searchEntry()
that can replace my first one.
<?php
$elasticSearchPlugin = KalturaElasticSearchClientPlugin::get($client);
$searchParams = new KalturaESearchEntryParams();
$searchParams->orderBy = new KalturaESearchOrderBy();
$searchParams->orderBy->orderItems = [];
$searchParams->orderBy->orderItems[0] = new KalturaESearchEntryOrderByItem();
$searchParams->orderBy->orderItems[0]->sortField = KalturaESearchEntryOrderByItem::PLAYS;
$searchParams->orderBy->orderItems[0]->sortOrder = KalturaESearchEntryOrderByItem::ORDER_BY_DESC;
$searchParams->searchOperator = new KalturaESearchEntryOperator();
$searchParams->searchOperator->searchItems = [];
$searchParams->searchOperator->searchItems[0] = new KalturaESearchEntryItem();
$searchParams->searchOperator->searchItems[0]->itemType = KalturaESearchItemType::RANGE;
$searchParams->searchOperator->searchItems[0]->fieldName = KalturaESearchEntryFieldName::CREATED_AT;
$searchParams->searchOperator->searchItems[0]->range = new KalturaESearchRange();
$searchParams->searchOperator->searchItems[0]->range->greaterThanOrEqual = 1612173489;
$pager = new KalturaPager();
try {
$result = $elasticSearchPlugin->eSearch->searchEntry($searchParams, $pager);
var_dump($result);
} catch (Exception $e) {
echo $e->getMessage();
}
?>