src/searchOld/elastic/helpers/IndexHelper.php
public static function primaryKeysByCondition($client, $condition)
    {
        $primaryKeys = [];
        $count = $client->count($condition);
        $count = empty($count['count']) ? 10 : $count['count'];
        $condition['size'] = $count;
        $condition['_source'] = true;
        $res = $client->search($condition);
        if (false === empty($res['hits']['hits'])) {
            foreach ($res['hits']['hits'] as $doc) {
                if (false === isset($primaryKeys[$doc['_id']])) {
                    $primaryKeys[$doc['_id']] = [$doc['_type']];
                } else {
                    if (false === in_array($doc['_type'], $primaryKeys[$doc['_id']])) {
                        $primaryKeys[$doc['_id']][] = $doc['_type'];
                    }
                }
            }
        }
        return $primaryKeys;
    }
public static function primaryKeysByCondition($client, $condition)
    {
        $primaryKeys = [];
        $count = $client->count($condition);
        $count = empty($count['count']) ? 10 : $count['count'];
        $condition['size'] = $count;
        $condition['_source'] = true;
        $res = $client->search($condition);
        if (false === empty($res['hits']['hits'])) {
            foreach ($res['hits']['hits'] as $doc) {
                if (false === isset($primaryKeys[$doc['_id']])) {
                    $primaryKeys[$doc['_id']] = [$doc['_type']];
                } else {
                    if (false === in_array($doc['_type'], $primaryKeys[$doc['_id']])) {
                        $primaryKeys[$doc['_id']][] = $doc['_type'];
                    }
                }
            }
        }
        return $primaryKeys;
    }
public static function primaryKeysByCondition ( $ client , $ condition ) { $ primaryKeys = [ ] ; $ count = $ client -> count ( $ condition ) ; $ count = empty ( $ count [ 'count' ] ) ? 10 : $ count [ 'count' ] ; $ condition [ 'size' ] = $ count ; $ condition [ '_source' ] = true ; $ res = $ client -> search ( $ condition ) ; if ( false === empty ( $ res [ 'hits' ] [ 'hits' ] ) ) { foreach ( $ res [ 'hits' ] [ 'hits' ] as $ doc ) { if ( false === isset ( $ primaryKeys [ $ doc [ '_id' ] ] ) ) { $ primaryKeys [ $ doc [ '_id' ] ] = [ $ doc [ '_type' ] ] ; } else { if ( false === in_array ( $ doc [ '_type' ] , $ primaryKeys [ $ doc [ '_id' ] ] ) ) { $ primaryKeys [ $ doc [ '_id' ] ] [ ] = $ doc [ '_type' ] ; } } } } return $ primaryKeys ; }
Performs fast scan for docs ids in elasticsearch indices

@param Client $client
@param array $condition query condition to find docs
@return array
Performs fast scan for docs ids in elasticsearch indices