lundi 6 avril 2015

MongoDB can't index large keys - unable to perform full-text search

I am developing a MEAN web app for books. I am trying to perform full-text search on my ebooks schema (I am using mongoose for the schemas):



var eBookSchema = mongoose.Schema({
title: {
type: String,
},
path: {
type: String,
required: '{PATH} is required'
},
chapters: {
type: [String],
required: '{PATH} is required',
text : true
},
uploaderID: {
type: ObjectId,
ref: 'User',
required: '{PATH} is required'
},
uploaded: {
type: Date,
default: Date.now
}
});


To perform the full-text search, I need a text index, as specified in the Mongo Docs. The problem is that the chapters contents are bigger than MongoDB's index key limit, which is 1024 bytes (docs). That's why I always get the following error when trying to insert a document:



Btree::insert: key too large to index


The document is inserted, but no index is created, and I cannot perform full-text search. I am open to any ideas. Can I define my schema in a different way, that will work with indexes? Or should I use some search server, like Solr or ElasticSearch?


Aucun commentaire:

Enregistrer un commentaire