如何在Api平台的Mongodb请求中添加“ AllowDiskUse:true”选项?

问题描述 投票:0回答:1

该项目将Api平台与mongodb结合使用。我有一个播放器文档,其中的姓氏排序。它可以容纳5000名玩家。当我与200,000名玩家进行测试时,出现错误:

排序超出内存限制,为104857600字节,但未选择加入外部排序。中止操作。传递allowDiskUse:true以选择in。

我需要在请求的选项中添加“ allowDiskUse:true”。

我尝试将其直接添加到ApiPlatform代码中进行测试,并且可以正常工作! (但是我无法将其添加到库中。)>

我的问题是:如何在Api平台的mongodb查询中添加选项“ allowDiskUse:true”?

/**
 * @ODM\Document(repositoryClass="App\Repository\PlayerRepository")
 * @ApiResource(
 *     attributes={"orders"={"lastName"= "ASC"}},
 *     collectionOperations={"get", "post"},
 *     itemOperations={"get", "put"},
 *
 *     normalizationContext={"groups"={"player"}},
 *     denormalizationContext={"groups"={"player"}}
 *     )
 */
class Player
{
    /**
     * @ODM\Id
     * @Groups({"player"})
     */
    private $id;

    /**
     * @ODM\Field(type="string")
     * @Groups({"player"})
     */
    private $optaId;

    /**
     * @ODM\Field(type="string")
     * @Groups({"player"})
     */
    private $firstName;

    /**
     * @ODM\Field(type="string")
     * @Groups({"player"})
     */
    private $lastName;

该项目将Api平台与mongodb结合使用。我有一个播放器文档,其中的姓氏排序。它可以容纳5000名玩家。当我与200,000名玩家一起测试时,出现错误:排序超出内存...

mongodb symfony doctrine-odm api-platform.com
1个回答
0
投票

您可以通过添加来实现

© www.soinside.com 2019 - 2024. All rights reserved.