2016-07-07 1 views
2

내 단위 테스트 용 mongoosastic을 사용하여 모델을 자릅니다. 내 mongoose 스키마의 bulkindex를 수행하기 전에.mongoosastic 저장 데이터가 없습니다.

스키마 :

model: { 
    name: {type: String, required: true, es_indexed: true, index: 'not_analyzed'}, 
    aliases: {type: [String], es_indexed: true, index: 'not_analyzed'}, 
    birth: {type: Date, es_type: 'date', es_indexed: true, index: 
}, 

스키마 플러그인 :

schema.plugin(mongoosastic, { 
    esClient, 
    index: model, 
    }); 

절단 :

Model.esTruncate(function (err) { 

     if (err) { 
      console.error(err); 
     } 

     console.log("[ElasticSearch] Model removed") 
     Model.indexFiles(); 
    }); 

인덱싱 :

Model.indexFiles = function() { 
    console.log('[ElasticSearch] Start indexing ' + entityName + ' documents'); 

    var stream = model.synchronize(); 
    var count = 0; 

    stream.on('data', function (err, doc) { 
     count++; 
    }); 
    stream.on('close', function() { 
     console.log('[ElasticSearch] Indexed ' + count + ' ' + entityName + ' documents!'); 
    }); 
    stream.on('error', function (err) { 
     console.log('mongoosastic ERROR'); 
     console.log(err); 
    }); 
    }; 

내가 로깅하고있어하지만 내 포스트 노선에서

Model.on('es-indexed', function (err, res) { 
    console.log('model added to es index'); 
}); 

, 내 ES는 빈 유지됩니다. 이유가 무엇인지 잘 모릅니다. 또한 Model.esSearch는 라이브러리에는 존재하지 않지만 라이브러리에는 문서화 된 기능입니다 https://github.com/mongoosastic/mongoosastic/issues/219 기본 esClient 사용을 진지하게 고려하고 있습니다. 이 라이브러리에 대한 귀하의 경험은 어떻습니까?

답변

0

이 경우 찾기가 어려울 수 있지만 필자의 경우 라이브러리가 아니 었습니다. 충분한 디스크 공간이 없기 때문에 내 ES 클러스터 상태가 빨간색이었습니다. 다음 시도 할 수 있습니다 : 해당 지역의 ES 인스턴스

  1. 중지
  2. 까지 약간의 디스크 공간
  3. 를 다시 시작
  4. 는 CURL에게 (컬 -XDELETE 'http://localhost:9200/model/')
  5. 색인화를 사용하여 굴절률들을 절단하여 ES 명확 귀하의 모델
  6. 여전히 문제가있는 경우 ES의 레코드 업데이트가 준 실시간이기 때문에 콜백에서 지연 및 로깅을 수행해야합니다. ...

    자르고 나를 위해 그것을 한 대량 색인

후 잠시 후 테스트를 실행