【问题标题】:How to index mongoose-timestamp in elastic search如何在弹性搜索中索引猫鼬时间戳
【发布时间】:2017-01-07 15:40:47
【问题描述】:

我们有一个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。请让我知道这些特定的选项可以完成这项工作。

【问题讨论】:

  • 如何索引文档?你用什么来索引?

标签: node.js elasticsearch mongoose mongoosastic


【解决方案1】:

您是否尝试过按照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 }
)

【讨论】:

    猜你喜欢
    • 2017-09-04
    • 2017-02-01
    • 2021-12-16
    • 2016-09-15
    • 1970-01-01
    • 2021-07-11
    • 2021-04-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多