MongoError: Too many fields

2

Hi,
We are migrating from MongoDB to DocumentDB and a problem has arisen: "MongoError: Too many fields". Aggregate works fine in MongoDB, but in DocumentDB it raised this error. So, what is the field limit to select/consider in an aggregate in DocumentDB?

질문됨 3년 전677회 조회
2개 답변
1
수락된 답변

I was unable to get the $project or $addFields stages to work with more than 50 fields and could not find any documentation surrounding this limit.

However, at least in the case of $project, it appears you can work around the limitation by combining multiple $addFields stages followed by a $replaceRoot stage:

db.mytable.aggregate([
  {
    $addFields: {
      out: {
        /** fields 1-50 */
      },
    },
  },
  {
    $addFields: {
      out: {
        /** fields 51-100 */
      },
    },
  },
  {
    $addFields: {
      out: {
        /** fields 101-150 */
      },
    },
  },
  {
    $replaceRoot: {
      newRoot: "$out",
    },
  },
]);
답변함 일 년 전
-1

Hi. You'll need to identify which actual stage in the aggregation pipeline is triggering the error. I've seen this error before on the $group stage, when there are too many fields to group by, there's a limit of 50 group fields.

AWS
Mihai A
답변함 2년 전
  • Our team has hit the same issue when using an aggregate call with a state that contains about 90 items. That 50 limit that you suggest. Is it mentioned anywhere on the DocumentDB documentation page? For example on the "Amazon DocumentDB Quotas and Limits" section - I am not able to find any information about that limit there.

  • We are experiencing this exact same error trying to do an aggregate() with a single $project stage. In testing an arbitrary list of with null valued $project fields, any field count over 50 produces a Too many fields. error from the server. I currently have a need to transform our documents with over 250 fields and because of this limitation, am not sure how to do it. I'm hoping this is configurable or I can find a workaround.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠