$orderByID = false; } else { $multiMatch = new ElasticsearchDSL\Query\MultiMatchQuery(['label^20', 'tags'], $SearchQuery, ['type' => 'cross_fields', 'minimum_should_match' => '100%']); $search->addQuery($multiMatch); } } else { $sort = new ElasticsearchDSL\Sort\FieldSort('order', 'asc'); $search->addSort($sort); } $boolquery = new BoolQuery(); if (Permission::insufficient('staff')) { $boolquery->add(new TermQuery('private', true), BoolQuery::MUST_NOT); } $boolquery->add(new TermQuery('ishuman', $EQG), BoolQuery::MUST); $search->addQuery($boolquery); $search->setSource(false); $search = $search->toArray(); $search = CGUtils::searchElastic($search, $Pagination); $Pagination->calcMaxPages($search['hits']['total']); if (!empty($search['hits']['hits'])) { $ids = []; foreach ($search['hits']['hits'] as $hit) { $ids[] = $hit['_id']; } $Ponies = $CGDb->where('id IN (' . implode(',', $ids) . ')')->orderBy('order', 'ASC')->get('appearances'); } } if (!$elasticAvail) { $_EntryCount = $CGDb->where('ishuman', $EQG)->where('id != 0')->count('appearances'); $Pagination = new Pagination('cg', $AppearancesPerPage, $_EntryCount); $Ponies = Appearances::get($EQG, $Pagination->getLimit());