Answer the question
In order to leave comments, you need to log in
How to organize an ElasticSearch mongoosastic index?
Good afternoon.
I can't figure out what I'm doing wrong.
There is a scheme
var ResponseSchema = new Schema({
date_create: {type: Date, default: Date.now},
author: {type: Schema.Types.ObjectId, ref: 'user', required: true},
text: {type: String, required: true, es_indexed: true, es_index_analyzer: "index_ru", es_search_analyzer: "search_ru"},
type: {type: String, default: 'response'},
type_status: String,
files: [{type: Schema.Types.ObjectId, ref: 'file'}],
task: {type: Schema.Types.ObjectId, ref: 'task'}
});
var TicketSchema = new Schema({
date_create: {type: Date, default: Date.now},
date_update: Date,
author: {type: Schema.Types.ObjectId, ref: 'user', required: true},
project: {type: Schema.Types.ObjectId, ref: 'project', required: true},
name: {type: String, required: true, es_indexed: true, es_index_analyzer: "index_ru", es_search_analyzer: "search_ru"},
text: {type: String, required: true, es_indexed: true, es_index_analyzer: "index_ru", es_search_analyzer: "search_ru"},
status: {type: String, default: 'wait_staff'},
labor: {type: Boolean, default: false},
files: [{type: Schema.Types.ObjectId, ref: 'file'}],
responses: {type: [ResponseSchema]}
});
TicketSchema.plugin(mongoosastic);
var Ticket = mongoose.model('ticket', TicketSchema);
Ticket.createMapping({}, function(err, mapping){
if (err) {
console.log(err);
} else {
console.log(mapping);
}
});
Answer the question
In order to leave comments, you need to log in
I would advise you to hang hooks on the models and manually do the indexing separately using the ES client, so you have more control over the process.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question