mongoosastic: not_analyzed parameter is not applied when indexing fields

Hi, I am indexing a mongoose model into Elasticsearch by specifying the fields using es_indexed: true, which worked fine.

Now I want some of those fields not to be analyzed by using the index: 'not_analyzed' option, but it doesn’t work.

I ran GET /actions/_mapping in Elasticsearch to check the mapping, and the option is not shown. Therefore I guess that mongoosastic is not passing it.

I also tried to delete the index from Elasticsearch to ensure that it takes my edits into consideration, but it didn’t change neither.

If I manually enter the index using PUT /actions, then it works, but the goal is to have it in the schema declaration, as below.

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'
  }]
});

Am I doing something wrong ? What should I do to make it work?

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 1
  • Comments: 23 (7 by maintainers)

Most upvoted comments

Also seeing this with latest ES 5.4 and mongoosastic 4.3.0. Just seems to igonre it, and digging into the source, I don’t see where this would’ve ever worked.

This is part of my working schema. With analized and not_analized indexed data.

MessageSchema = new mongoose.Schema({
  ts: {type: Date, default: Date.now, required: true},  
  details: {
    title: {type: String, trim: true, match: /\S+/, required: true, es_indexed: true },
  },
  scope: {
    nbhd: {
      city: {type: String, trim: true, es_indexed: true, es_index: 'not_analyzed'},
      zipCode: {type: String, trim: true, es_indexed: true, es_index: 'not_analyzed'},
   }
 }
}, {versionKey: false});

MessageSchema.plugin(mongoosastic);

var model = mongoose.model('Message', MessageSchema);