[SERVER-30272] Found an index like {fieldName: 0} Created: 22/Jul/17  Updated: 27/Oct/23  Resolved: 24/Jul/17

Status: Closed
Project: Core Server
Component/s: Index Maintenance
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Nic Cottrell (Personal) Assignee: Kelsey Schubert
Resolution: Works as Designed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to SERVER-769 Validate top-level & index spec field... Closed
Operating System: ALL
Participants:

 Description   

I just did a mongodump and mongorestore and got an error:

{{code}
Failed: jerome5.Unit: error creating indexes for jerome5.Unit: createIndex error: Values in the index key pattern cannot be 0.
code

I checked on the source collection and found an index like:

code
{
"key":

{ "f": 0.0 }

,
"name": "f_0",
"ns": "jerome5.Unit",
"v": 1
},
code

I'm not sure how long this has been there, but I suppose it doesn't actually do anything on the source database? Maybe it is assumed to be 1 if it's not -1 ?



 Comments   
Comment by Nic Cottrell (Personal) [ 25/Jul/17 ]

Thanks Thomas. Glad that it's already been addressed.

Comment by Kelsey Schubert [ 24/Jul/17 ]

Hi niccottrell,

Thanks for reporting this behavior. You're correct that it is treated as an ascending index if it's not -1. See SERVER-8638, which was closed as a duplicate of SERVER-769. SERVER-769 was fixed in MongoDB 3.4, and adds validation to index creation commands. Therefore, I suspect that this index was created on some earlier version of MongoDB.

To resolve this issue, I would recommend dropping this index and recreating it with the correct specifications.

Kind regards,
Thomas

Generated at Thu Feb 08 04:23:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.