2016-08-31 70 views
1

我们有一个mongoose对象,其模式如下,使用timestamps,我们正在填充createdAt & updatedAt字段。我们使用mongoosastic在弹性搜索中对这些进行索引。如何索引弹性搜索中的猫鼬时间戳

var mongoose = require("mongoose"); 
var employeeSchema = new mongoose.Schema(
    { 
     name: { 
       type: String 
       es_indexed: true, 
       es_index:"analyzed" 
       }, 
     managerId: {type: mongoose.Schema.Types.ObjectId}, 
     details:{}, 
     email: { 
       type: String 
       es_indexed: true, 
       es_index:"analyzed" 
       }, 
     phone: { 
       type: Number 
       es_indexed: true, 
       es_index:"analyzed" 
       } 
    }, 
    { 
     timestamps: true 
    }); 

我想指数updatedAt以及弹性的搜索,但不知道如何与mongoosastic做到这一点。请让我知道这些具体的选项来完成这个。

+0

你是如何索引文件?你用什么来索引? – hkulekci

回答

0

您是否试过根据docs映射日期? 所以,像

var ExampleSchema = new Schema({ 
     // Date (core type) 
     createdAt: {type:Date, es_type:'date', es_indexed: true}, 
     updatedAt: {type:Date, es_type:'date', es_indexed: true} 
    }, 
    { timestamps: true } 
)