2016-08-31 71 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 } 
)