0

I'm trying to index an existing collection to ElasticSearch using the mongoosastic plugin for NodeJs. This my schema:

const callCenterSchema = new mongoose.Schema({
    _owner : { type: mongoose.Schema.Types.ObjectId, ref: 'User', es_type: 'object' },
    ivrs: [{
        name: {
            type: String,
            es_type: 'string'
        },
        ivrType: {
            type: String,
            default: 'mobile',
            enum: ['mobile', 'website'],
            es_type: 'string'
        },
        submenu: {
            type: [ CallCenterSubmenu.schema ],
            es_type: 'nested',
            es_include_in_parent: true
        }
    }]
});

callCenterSchema.plugin(mongoosastic, {
    esClient: require('tusla/lib/db/elastic').elastic,
    populate: [
        { path: '_owner' }
    ]
});

let CallCenter = mongoose.model('CallCenter', callCenterSchema);
CallCenter.synchronize()

CallCenter.createMapping(function(err, mapping) {
  if (err) {
    console.error('Error creating mapping for CallCenters', err.message);
  }
});


module.exports = CallCenter;

My submenu schema is like this:

const callcenterSubmenuSchema = new mongoose.Schema({
    name: String,
    key: String,
    waitTime: {
        type: Number
    },
    waitSuffix: String,
    numberOrLink: String,
    auth: {
        canBeSkipped: String,
        fields: {
            type: Array,
            es_type: 'object'
        },
        verification: String,
        regExp: String
    },
    submenu: [this]
}, { _id: false });

I keep getting this specific error, but couldn't solve it. I appreciate if you guys can help me.

Thanks!

Error creating mapping for CallCenters [mapper_parsing_exception] No handler for type [mixed] declared on field [submenu]

2
  • What is CallCenterSubmenu.schema? Commented Aug 2, 2016 at 16:43
  • I've given the submenu schema on below the first schema. Commented Aug 2, 2016 at 21:53

1 Answer 1

1

I guess the problem is that line:

 type: [ CallCenterSubmenu.schema ]

In error message it says:

No handler for type [mixed] declared on field [submenu]

So you are trying to specify the type of submenu field as fixed (or elasticsearch infers it as I am not sure) and as I know there is no type as mixed. So ES fires that exception. You must specify a valid type: https://www.elastic.co/guide/en/elasticsearch/reference/master/mapping-types.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.