Sunday, 4 June 2017

MongoDB Fails Because Key Too Large To Index

I have been attempting to save a MongoDB document, and am getting a strange error concerning the key being too large to index. I have provided an example of a functional document below, as well as one that creates an error:

Functional:

{ uniquenumber: '10460',
  name: 'METHODS TEACH BIOL LAB',
  fieldofstudy: 'BIOL',
  section: 600,
  restrictions:
   { 'Must be assigned one of the following Student Attributes':
      [ 'Non-Res. In-State',
        'Non-Res. Out-of-State',
        'DE Student Non-Res Out-of-St',
        'Resident In-State',
        'Res. Out-of-State' ],
     'Must be enrolled in one of the following Levels': [ 'Graduate' ] },
  _id: 59345fab146ca32588292b0c,
  times: [],
  professors: [ 'Jo Blo' ] }

Non-Functional:

{
    "uniquenumber": "18373",
    "name": "PROFESSIONAL STUDY",
    "fieldofstudy": "ALEC",
    "section": 707,
    "restrictions": {
        "May not be enrolled in one of the following Programs": ["MA [LA] Non-thesis option", "MS [AG] Non-thesis option", "MS [AR] Non-thesis option", "MS [BA] Non-thesis option", "MS [COFD] Non-thesis option", "MS [ED] Non-thesis option", "MS [EN] Non-thesis option", "MS [GE] Non-thesis option", "MS [LA] Non-thesis option", "MS [SC] Non-thesis option", "MS [VM] Non-thesis option", "MS NTO (Special Programs)", "MUP [AR] Non-thesis option"],
        "Must be enrolled in one of the following Levels": ["Graduate"],
        "May not be enrolled in one of the following Degrees": ["Master of Agribusiness", "Master of Agriculture", "Master of Architecture", "Master of Business Admin.", "Master of Computer Science", "Master of Education", "Master of Engineering", "Master of Land Econ & Real Est", "Master of Geoscience", "Master of Landscape Arch.", "Master of Public Administratn", "Master of Public Health", "Master of Public Svc & Admin"],
        "May not be enrolled in one of the following Colleges": ["English Language Institute"],
        "Must be assigned one of the following Student Attributes": ["Non-Res. In-State", "Non-Res. Out-of-State", "DE Student Non-Res Out-of-St", "Resident In-State", "Res. Out-of-State"],
        "Must be enrolled in one of the following Classifications": ["G7-Graduate, Master's Level", "G8-Graduate, Doctoral Level", "G9-Graduate, Mas/Doc Admitted"]
    },
    "times": [],
    "professors": []
}

Up until the creation of the restrictions object, the scraper was functioning as expected, so I believe the error can be narrowed down to there. However, it is unclear to me where any key is "too large" to be indexed. If my guess is correct, why is Mongo counting it as a key and how can I remedy the situation?



via Quontas

No comments:

Post a Comment