matteodem / meteor-easy-search

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

"Match error: Expected Collection", path: "" #638

Open krit-gpt opened 6 years ago

krit-gpt commented 6 years ago

I am getting an error, while I try to create an index in a separate indexes.js file. The exact line where I create an index causes the error. The exact error is as follows:

match.js:42 Uncaught
errorClass {message: "Match error: Expected Collection", path: "", sanitizedError: errorClass, errorType: "Match.Error", stack: "Error: Match error: Expected Collection↵    at che…c9cbd8d132b04d4a012690341aa7e009ee6d5cd8:5367:14)"}
errorType: "Match.Error"
message:"Match error: Expected Collection"
path:""
sanitizedError:errorClass
details:undefinederror:400
errorType:"Meteor.Error"
isClientSafe:true
message:"Match failed [400]"
reason:"Match failed"
stack:"Error: Match failed [400]↵    at errorClass.<anonymous> (http://localhost:3000/packages/check.js?hash=7d8a6e550ea7ab9936e21a2d9bb76f12882fb043:142:27)↵    at new errorClass (http://localhost:3000/packages/meteor.js?hash=c9a34f92f28ede5a42eac467d3fa1763b624436a:626:17)↵    at check (http://localhost:3000/packages/check.js?hash=7d8a6e550ea7ab9936e21a2d9bb76f12882fb043:89:15)↵    at Index (http://localhost:3000/packages/easysearch_core.js?hash=3bdd42bdedfe50655b11d30e03ec30263f50dd6e:75:40)↵    at new Index (http://localhost:3000/packages/easysearch_components.js?hash=2b6ce11740f0470992d652b361df53fa0268bbf0:530:31)↵    at indexes.js (http://localhost:3000/app/app.js?hash=c9cbd8d132b04d4a012690341aa7e009ee6d5cd8:5013:22)↵    at fileEvaluate (http://localhost:3000/packages/modules-runtime.js?hash=9f9bb5e055614ddf4eb3e743737b7a5b3cfd9d34:353:9)↵    at require (http://localhost:3000/packages/modules-runtime.js?hash=9f9bb5e055614ddf4eb3e743737b7a5b3cfd9d34:248:16)↵    at company-search-trial.jsx (http://localhost:3000/app/app.js?hash=c9cbd8d132b04d4a012690341aa7e009ee6d5cd8:4010:14)↵    at fileEvaluate (http://localhost:3000/packages/modules-runtime.js?hash=9f9bb5e055614ddf4eb3e743737b7a5b3cfd9d34:353:9)"
__proto__
:
Errorstack:"Error: Match error: Expected Collection↵    at check (http://localhost:3000/packages/check.js?hash=7d8a6e550ea7ab9936e21a2d9bb76f12882fb043:89:15)↵    at Index (http://localhost:3000/packages/easysearch_core.js?hash=3bdd42bdedfe50655b11d30e03ec30263f50dd6e:75:40)↵    at new Index (http://localhost:3000/packages/easysearch_components.js?hash=2b6ce11740f0470992d652b361df53fa0268bbf0:530:31)↵    at indexes.js (http://localhost:3000/app/app.js?hash=c9cbd8d132b04d4a012690341aa7e009ee6d5cd8:5013:22)↵    at fileEvaluate (http://localhost:3000/packages/modules-runtime.js?hash=9f9bb5e055614ddf4eb3e743737b7a5b3cfd9d34:353:9)↵    at require (http://localhost:3000/packages/modules-runtime.js?hash=9f9bb5e055614ddf4eb3e743737b7a5b3cfd9d34:248:16)↵    at company-search-trial.jsx (http://localhost:3000/app/app.js?hash=c9cbd8d132b04d4a012690341aa7e009ee6d5cd8:4010:14)↵    at fileEvaluate (http://localhost:3000/packages/modules-runtime.js?hash=9f9bb5e055614ddf4eb3e743737b7a5b3cfd9d34:353:9)↵    at require (http://localhost:3000/packages/modules-runtime.js?hash=9f9bb5e055614ddf4eb3e743737b7a5b3cfd9d34:248:16)↵    at router.jsx (http://localhost:3000/app/app.js?hash=c9cbd8d132b04d4a012690341aa7e009ee6d5cd8:5367:14)"
__proto__
:
Error

The exact line where I create an index causes the error.

import { Index, MinimongoEngine } from 'meteor/easy:search';
import Companies from './companies.js';

// On Client and Server
export const CompaniesIndex = new Index({
  collection: Companies,
  fields: ['name'],
  engine: new MinimongoEngine()
});

I read about the similar issue, and still cant figure out what to do in order to rectify this, and that thread was closed. Hence, had to open a new issue. Please tell me what to do in order to rectify this. Thanks.

matteodem commented 3 years ago

Is companies a Meteor.Collection? The error states what is happening (a match error).

matteodem commented 3 years ago

If yes, a reproduction repo or more code would be very helpful.