matteodem / meteor-easy-search

Easy-to-use search for Meteor with Blaze Components
MIT License
437 stars 68 forks source link

Searching on nested values #500

Closed SoSufi closed 7 years ago

SoSufi commented 8 years ago

I'm trying to create a index for array values in my collection but I'm getting errors in creating such an index.

My Collection is { "_id" : ObjectId("573ae8718d1a32ab1bcdc5aa"), "Categories" : [ { "categoryNo" : "1", "faq" : [ { "questionNo" : "1", "question" : "What is the quality ",}] }]}

below I'm trying to create index to search question.

FaqsIndex = new EasySearch.Index({ collection: Faqs, fields: ['Faqs.Categories.faq.question'], engine: new EasySearch.MongoDB({ }), defaultSearchOptions: { limit: 10 }, permission: () => { //console.log(Meteor.userId());

return true;

} });

Please point me to the correct direction.

matteodem commented 7 years ago

For complex use cases try to simplify your data structure (denormalize) or do [following(http://matteodem.github.io/meteor-easy-search/docs/recipes/).