使用mongoosastic时,在将字段索引到Elasticsearch时不会应用not_analyzed参数

时间:2015-04-21 21:43:58

标签: elasticsearch mongoosastic

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

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

我在Elasticsearch中运行GET /actions/_mapping来检查映射,但未显示该选项。因此我猜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

1 个答案:

答案 0 :(得分:0)

在 mongoosastic es_ 应该是架构中的前缀。

尝试 ->

es_index: "not_analyzed"