将Laravel中的Elasticsearch查询转换为MongoDB结构

0yycz8jy  于 12个月前  发布在  ElasticSearch
关注(0)|答案(1)|浏览(213)
private function comparedProduct()
{
    $this->info('Create for compared product');

   $comparedProductParam =
    [
        'meta_field' => 1,
        'with_scroll_id' => 1,
        'scroll' => $this->scrollDuration,
        'scroll_size' => $this->perPage,
        'index' => 'compared_product',
        'sort' => [["created_at" => ["order" => "ASC"]]],
    ];
    $scrollIdForComparedProduct = $this->esProductService->findBy($comparedProductParam);
    $skip = 0;
    $limit = $this->perPage; 

   // $comparedProducts = ComparedProduct::orderBy('created_at', 'asc')->skip($skip)->limit($limit)->get()->toArray();

    $comparedProducts = fillOnUndefined($scrollIdForComparedProduct, 'response', []);

    $this->info('compared product is : 1');

    $this->storeComparedProduct($comparedProducts);

    for ($i=2; $i <= 15; $i++)
    {
        $this->info('compared product is : '.$i);

        $scrollParam =
        [
            'scroll_id' => $scrollIdForComparedProduct['scroll_id'],
            'scroll' => $this->scrollDuration
        ];
        $response = $this->esProductService->scroll($scrollParam);
        if(!$response['response'])
        {
            continue;
        }

        $this->storeComparedProduct($response['response']);
    }

}

字符串
我想将这个Elasticsearch查询转换为MongoDB结构,但我无法正确地完成它。我如何将Elasticsearch中使用的scroll方法适应MongoDB,以及如何在条件中正确地提供它?

sy5wg1nm

sy5wg1nm1#

所有类似的活动你会发现在$skip$limit.在所有的查询动作,结果是分页使用$skip$limit.但它将是必要的通过参数像pageperPagelimit
->skip(10)->limit(10)-将是下一个10个实体。
1.创建查询
1.在何处、分类等

  1. paginate

相关问题