Я пытаюсь реализовать поисковую систему в node.js, используя elasticSearch + mongose, который является elmongo. Всякий раз, когда я пытаюсь запустить API поиска я получаю "ошибка": "IndexMissingException [[объявления] отсутствует]"Упругий поиск возврата IndexMissingException
Вот код
advertisingSchema.js
var mongoose = require('mongoose');
var elmongo = require('elmongo');
var Schema = mongoose.Schema;
var AdSchema = new Schema({
title: String,
description: String,
category: String,
phoneNumber: { type: Number, unique: true},
photos: [{ type: String }],
created: { type: Date, default: Date.now},
price: Number,
password: String
});
AdSchema.plugin(elmongo);
module.exports = mongoose.model('Ad', AdSchema
);
api.js
var Ad = require('../models/advertising');
module.exports = function(app, express) {
var api = express.Router();
Ad.sync(function(err) {
console.log("Check the number sync");
})
api.post('/search', function(req, res) {
Ad.search(req.body, function(err, result){
if(err) {
res.send(err);
return;
}
res.json(result);
});
});
return api;
}
Я сделал все правильно, но его просто не хочет возвращать результат поиска.