2016-08-02 8 views
0

NodeJs 용 mongoosastic 플러그인을 사용하여 기존 컬렉션을 ElasticSearch로 색인화하려고합니다. 이 내 스키마MongoDB with Mongoosastic

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; 

내 하위 스키마는 다음과 같이이다 :

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 }); 

내가이 특정 오류가 계속하지만, 그것을 해결하지 못했습니다. 너희들이 나를 도울 수 있으면 고맙다.

감사합니다.

type: [ CallCenterSubmenu.schema ] 

오류 메시지에서이 말한다 : CallCenters에 대한

을 만드는 중 오류 매핑 [mapper_parsing_exception] [혼합] 유형에 대한 어떠한 핸들러가 필드를 선언하지 않습니다 [메뉴] 나는이 문제를 추측

+0

CallCenterSubmenu.schema 란 무엇입니까? – alpert

+0

첫 번째 스키마 아래에 하위 메뉴 스키마를 지정했습니다. – Yagiz

답변

1

그 라인 : 내가 아니라고으로

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

그래서 당신은 fixed으로 submenu 필드의 유형을 지정하려는 (또는 elasticsearch은을 유추 물론) 그리고 내가 아는 바에는 mixed과 같은 유형이 없습니다. 따라서 ES는 예외를 발생시킵니다. 유효한 유형을 지정해야합니다. https://www.elastic.co/guide/en/elasticsearch/reference/master/mapping-types.html