Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.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
Mongo PHP-查找$criteriaw/$regex超时_Php_Mongodb - Fatal编程技术网

Mongo PHP-查找$criteriaw/$regex超时

Mongo PHP-查找$criteriaw/$regex超时,php,mongodb,Php,Mongodb,我正在对数据集执行MongoDB find()。我的数据集总共有超过一百万个文档,索引上的键尽可能多。我确信,该系列本身已尽可能优化 “我的应用”允许您对收藏运行高级搜索。我刚刚尝试了一个新功能,它可以让你在已经很复杂的搜索过滤器上运行一个通用的“不得包含”过滤器。问题是搜索现在已经超过了Mongo的30秒限制!如果没有常规的“不得包含”过滤器,我的示例搜索大约需要5秒钟。如果我减少涉及的关键点,搜索就会及时返回 搜索的目标是返回在指定的任何键中不包含“ARSB”的文档(每个文档中总是有大量其他

我正在对数据集执行MongoDB find()。我的数据集总共有超过一百万个文档,索引上的键尽可能多。我确信,该系列本身已尽可能优化

“我的应用”允许您对收藏运行高级搜索。我刚刚尝试了一个新功能,它可以让你在已经很复杂的搜索过滤器上运行一个通用的“不得包含”过滤器。问题是搜索现在已经超过了Mongo的30秒限制!如果没有常规的“不得包含”过滤器,我的示例搜索大约需要5秒钟。如果我减少涉及的关键点,搜索就会及时返回

搜索的目标是返回在指定的任何键中不包含“ARSB”的文档(每个文档中总是有大量其他不相关的键)。我不能简单地在每个键上运行
$regex
的原因是,如果您这样做,搜索不会返回缺少任何一个键的文档

该应用程序在PHP脚本中运行
find()
查询。下面是慢速搜索
$criteria

{
  "$and": [
    {
      "$or": [
        {
          "columnOne": {
            "$regex": "^((?!ARSB).)*$",
            "$options": "-i"
          }
        },
        {
          "columnOne": {
            "$exists": false
          }
        }
      ]
    },
    {
      "$or": [
        {
          "secondColumn": {
            "$regex": "^((?!ARSB).)*$",
            "$options": "-i"
          }
        },
        {
          "secondColumn": {
            "$exists": false
          }
        }
      ]
    },
    {
      "$or": [
        {
          "finalColumn": {
            "$regex": "^((?!ARSB).)*$",
            "$options": "-i"
          }
        },
        {
          "finalColumn": {
            "$exists": false
          }
        }
      ]
    },
    {
      "$or": [
        {
          "columnOne": {
            "$exists": true
          }
        },
        {
          "secondColumn": {
            "$exists": true
          }
        },
        {
          "finalColumn": {
            "$exists": true
          }
        }
      ]
    }
  ]
}
是什么让搜索如此缓慢?有什么办法吗