mongoose-elasticsearch-xp icon indicating copy to clipboard operation
mongoose-elasticsearch-xp copied to clipboard

Unable to use field type "completion" from elasticsearch

Open yvsssantosh opened this issue 7 years ago • 3 comments
trafficstars

The documentation is not so clear, so I had to ask this question,

Let's take for example I have this sample.js model

'use strict'

const Joi = require('joi')
const Mongoose = require('mongoose')
const Joigoose = require('joigoose')(Mongoose)

const MongoosasticXP = require('mongoose-elasticsearch-xp')

let SampleJoi = Joi.object().keys({
  name: Joi.string().meta({es_indexed: true, /* es_type: 'completion' ? */})
  // When I give es_type as completion, it still creates the type
  // as keyword but not completion. I'm trying to implement auto
  // complete using suggester in elasticsearch
  //...
  // Some schema
})

Here is the mapping generated from mongoose-elasticsearch-xp

{
  "samples": {
    "mappings": {
      "Sample": {
        "properties": {
          "name": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword", // I want this to be of type completion
                "ignore_above": 256
              }
            }
          }
        }
      }
    }
  }
}

yvsssantosh avatar Mar 21 '18 08:03 yvsssantosh

I have the same problem, except for me the type is converted to object...

@jbdemonte Suggestions?

mikevercoelen avatar Jul 26 '18 03:07 mikevercoelen

I had the similar problem. I think you need to call esCreateMapping to create the mapping manually.

lhxatus avatar May 22 '19 04:05 lhxatus

@lhxatus could you please provide with some sample, using esCreateMapping for type completion as i am using suggest in my mapping

teamdraftbox avatar Mar 19 '20 05:03 teamdraftbox