jbdemonte / mongoose-elasticsearch-xp

A mongoose plugin that indexes models into Elasticsearch 2 / 5 / 6 and 7
93 stars 34 forks source link

[Bag] ResponseError: index_not_found_exception #80

Open IlyaShkurenko opened 3 years ago

IlyaShkurenko commented 3 years ago

After indexing all documents I see this error in console and index is not created on elastic search. Strange because 4 other collections were synced fine and this one is the simplest

const mongoose = require('mongoose');

const esClient = require('../elasticsearch/connection');
const { synchronize } = require('../elasticsearch/mongo_sync');
const mexp = require('mongoose-elasticsearch-xp');
const Schema = mongoose.Schema;

const imageClassTypeSchema = new Schema({
  class_type_id: { type: String },
  class_type_name: { type: String }
});

const productMediaSchema = new Schema(
  {
    url: { type: String, es_indexed: true, es_type: 'text' },
    isDefault: { type: Boolean, es_indexed: true },
    urlSmall: { type: String, required: true, es_indexed: true, es_type: 'text' },
    urlOrigin: { type: String, required: true, index: true, es_indexed: true, es_type: 'text' },
    product: { type: mongoose.Schema.Types.ObjectId, ref: 'Product', required: true, index: true },
    productPart: { type: mongoose.Schema.Types.ObjectId, ref: 'ProductPart', index: true },
    part_id: { type: String },
    partId: { type: String },
    classTypeId: { type: String },
    classTypeName: { type: String },
    decorationName: { type: String },
    height: { type: String },
    width: { type: String },
    classTypes: [imageClassTypeSchema],
    color: { type: String },
    fileSizeKb: { type: String },
    status: { type: String, es_indexed: true, es_type: 'text' },
    compressedSize: { type: String }
  },
  { timestamps: true }
  );

productMediaSchema.plugin(mexp, {
  client: esClient.client
});

const ProductMedia = mongoose.model('ProductMedia', productMediaSchema, 'productMedia');

let counter = 0;
ProductMedial.on('es-bulk-sent', function () {
   console.log('buffer sent');
});

ProductMedia.on('es-bulk-data', function (doc) {
  counter++
  console.log(model.collection.collectionName + ': ' + counter);
});

model.on('es-bulk-error', function (err) {
  console.error(err);
});
ProductMedia
  .esSynchronize(query)
  .then(function () {
     console.log('end.');

<img width="1091" alt="Снимок экрана 2021-04-01 в 01 08 16" src="https://user-images.githubusercontent.com/25804693/113217992-6fde1e00-9287-11eb-94f2-7d6335c09658.png">
});
DhifMlak commented 3 years ago

i pretty much have the same issue.

thejmill commented 3 years ago

We are also experiencing this issue.