尽管按照有关如何配置Elastic Search Package向我的Meteor App添加搜索功能的说明进行了认真的操作,但我仍然在浏览器控制台中收到以下令人沮丧的错误消息:
details: undefined
error: "no-index"
errorType: "Meteor.Error"
isClientSafe: true
message: "Please provide an index for your component [no-index]"
reason: "Please provide an index for your component"
stack: "Error: Please provide an index for your component [no-index]
以下是我的代码:
../ imports / api / tasks.js
import { Mongo } from "meteor/mongo";
import { Index, MinimongoEngine } from 'meteor/easy:search';
global.recipientsDetails = new Mongo.Collection("recipients");
global.recipientsDetailsIndex = new Index({
collection: recipientsDetails,
fields: ['recipientNumber', 'recipientAmount'],
engine: new MinimongoEngine(),
})
../ client / main.js
import '../imports/api/tasks.js';
Template.navigationMenu.helpers({
enableButtonSearchResults: () => recipientsDetailsIndex,
});
../ client / main.html
<template name="navigationMenu">
{{#EasySearch.Each index=recipientsDetailsIndex}}
<ul>
{{#EasySearch.Each index=recipientsDetailsIndex }}
<li>Recipients Number: {{recipientNumber}}</li>
{{/EasySearch.Each}}
</ul>
</template>
当我在浏览器控制台中输入以下代码时,我感到很奇怪:
var cursor = recipientsDetailsIndex.search("705087688");
// search all docs that contain "705087633" in the recipientNumber field.
console.log(cursor.fetch());
浏览器控制台中的以下内容:
[{…}]
0:
paymentDate: "2019-04-08 23:20:01"
recipientAmount: "110"
recipientNumber: "+254705087688"
_id: "Wo4oZNzs5fLTqadcn"
以上结果表明,弹性搜索包正在运行,并且故障出在模板中,尽管我可能是错的。
请帮助指出模板或其他地方缺少或错了什么...
答案 0 :(得分:1)
这里很容易猜到:但是http://matteodem.github.io/meteor-easy-search/docs/engines/提到有一个Elastic Search Engine,在您的任务文件中,您使用MiniMongoEngine ...