key is to large too index

825 views
Skip to first unread message

Paulo

unread,
Apr 21, 2015, 6:07:26 AM4/21/15
to mongod...@googlegroups.com
Hi,

I have string type fields with more than 255 characters. and I need to create an index on them.
When creating the index received a "key is too large to index". How can I do this. I really need this field and indexed.

output of error:

db.managedObjects.createIndex({"m.pr.v":1})
{
        "createdCollectionAutomatically" : false,
        "numIndexesBefore" : 4,
        "errmsg" : "exception: WiredTigerIndex::insert: key too large to index, failing  1098 { : \"PERFENH_AMR_SPEC_BR_
SWITCH-1&PERFENH_AMR_TMPLT_SWITCH-1&PERFENH_SRB_TMPLT_SWITCH-1&PERFENH_OLPC_TMPLT_SWITCH-1&PERFENH_AMR_SP_TMPLT_SWITCH-1
&PERFENH_I...\" }",
        "code" : 17280,
        "ok" : 0
}

Best Regards

-Paulo

Paulo

unread,
Apr 21, 2015, 6:20:38 AM4/21/15
to mongod...@googlegroups.com
I've tried too create an hashed index in this field. but is not possible create hashed index in array fields.

Asya Kamsky

unread,
Apr 21, 2015, 8:09:21 AM4/21/15
to mongodb-user

You have to make sure the value of the field is less than 1024 chars (or 1012).

What does the string represent?

Asya

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/45f23871-fe5e-4730-8b83-6cd471c1db29%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Paulo

unread,
Apr 21, 2015, 8:40:28 AM4/21/15
to mongod...@googlegroups.com
the string represent a list of data. and yes, sometimes this field have more than 1024 chars.

Isn't possible index fields > 1024 chars?

Paulo

unread,
Apr 21, 2015, 9:41:39 AM4/21/15
to mongod...@googlegroups.com
this field was initially a dictionary. something like:

{
  _id: 98987,
  objs:[
     props: [
       {k: "key", v: [{_t: "dictionary", _v:[{"field":"value", ... } ] } ] }        

    ]
  ]  



the document had other fields, but these are the ones that matter in this case.

I need the index in the field "objs.props.v", but was getting the error "key too large to index".

Then I tried another aproach, put this dictionary on the root of the field v (objs.props.v) as a string (field1:value1&field2:value2&......). but I get the same error (key is too large to index).

I really need this fields indexed. 

regards
-paulo

Asya Kamsky

unread,
Apr 24, 2015, 3:36:57 AM4/24/15
to mongod...@googlegroups.com
No, it's not possible to index fields > 1024 bytes.


On Tuesday, April 21, 2015, Paulo <pauloan...@gmail.com> wrote:
the string represent a list of data. and yes, sometimes this field have more than 1024 chars.

Isn't possible index fields > 1024 chars?

--
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.
 
For other MongoDB technical support options, see: http://www.mongodb.org/about/support/.
---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
To post to this group, send email to mongod...@googlegroups.com.
Visit this group at http://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/5857c882-f693-43e6-81dd-2c329f23aecc%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
MongoDB World is back! June 1-2 in NYC. Use code ASYA for 25% off!

Reply all
Reply to author
Forward
0 new messages