2

我正在使用mongoosastic将 mongoose 模型索引到 Elasticsearch 中,并使用 指定字段es_indexed: true,效果很好。

现在我希望不使用该index: 'not_analyzed'选项分析其中一些字段,但它不起作用。

GET /actions/_mapping在 Elasticsearch 中运行以检查映射,但未显示该选项。因此,我猜 mongoosastic 没有通过它。

我还尝试从 Elasticsearch 中删除索引以确保它考虑到我的编辑,但它也没有改变。

如果我使用 手动输入索引PUT /actions,那么它可以工作,但目标是在模式声明中包含它,如下所示。

var actionSchema = exports.Schema = mongoose.Schema({
  published: {
    type: Date,
    default: Date.now,
    es_indexed: true
  },
  actorUser: {
    type: ObjectId,
    ref: 'User',
    es_indexed: true
  },
  actor: {
    type: activityObject,
    es_indexed: true
  },
  pictureUrl: String,
  verb: {
    type: String,
    es_indexed: true,
    index: 'not_analyzed'
  },
  object: {
    type: activityObject,
    es_indexed: true
  },
  target: {
    id: {
      type: String,
      es_indexed: true
    },
    displayName: {
      type: String,
      es_indexed: true,
      index: 'not_analyzed'
    },
    objectType: {
      type: String,
      es_indexed: true
    },
    image: String,
    url: String
  },
  path: {
    type: String,
    es_indexed: true
  },
  recipients: [{
    type: ObjectId,
    ref: 'User'
  }]
});

知道我应该怎么做才能让它工作吗?

[编辑] 我在 mongoosastic GitHub 存储库上问了这个问题,该问题目前被标记为可能的错误:https ://github.com/mongoosastic/mongoosastic/issues/76

4

1 回答 1

0

在 mongoosastic 中,es_ 应该是模式中的前缀。

尝试 ->

es_index: "not_analyzed"
于 2021-08-11T06:16:20.457 回答