1

我们有一个具有如下模式的猫鼬对象,使用 时间戳,我们正在填充 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。请让我知道这些特定的选项可以完成这项工作。

4

1 回答 1

1

您是否尝试过按照文档映射日期?所以,像

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 }
)
于 2017-01-13T06:56:56.033 回答