Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何添加选项";AllowDiskUse:true“;在使用Api平台的Mongodb请求中?_Mongodb_Symfony_Doctrine Odm_Api Platform.com - Fatal编程技术网

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

如何添加选项";AllowDiskUse:true“;在使用Api平台的Mongodb请求中?,mongodb,symfony,doctrine-odm,api-platform.com,Mongodb,Symfony,Doctrine Odm,Api Platform.com,本项目使用Api平台和mongodb。 我有一个按姓氏排序的播放器文档。有5000名玩家,它可以工作。 当我测试200000名玩家时,我有一个错误: 排序超出了104857600字节的内存限制,但未选择加入 外部排序。正在中止操作。Pass allowDiskUse:对opt为真 在 我需要在请求的选项中添加“allowDiskUse:true” 我试着将它直接添加到ApiPlatform代码中进行测试,结果很好!(但我无法将其添加到库中) 我的问题是:如何在使用Api平台的mongodb查询中

本项目使用Api平台和mongodb。 我有一个按姓氏排序的播放器文档。有5000名玩家,它可以工作。 当我测试200000名玩家时,我有一个错误:

排序超出了104857600字节的内存限制,但未选择加入 外部排序。正在中止操作。Pass allowDiskUse:对opt为真 在

我需要在请求的选项中添加“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;

您可以通过添加

* @ApiResource(attributes={
*     "doctrine_mongodb"={
*       "execute_options"={
*         "allowDiskUse"=true
*       }
*     }
* })