Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect Mapping Created for Nested Types #79

Closed
nkoterba opened this issue Dec 25, 2013 · 4 comments
Closed

Incorrect Mapping Created for Nested Types #79

nkoterba opened this issue Dec 25, 2013 · 4 comments

Comments

@nkoterba
Copy link

Trying to use ElasticSearch's Facet Terms capability. To do so, I need to set one of my fields to use the "keyword" analyzer instead of the default.

Here is my code:

var chatSchema = new Schema({
        cluster: String,
        time: Number,
        room: {type:String, es_indexed:true, es_analyzer:'keyword'},
        user: {type:String, es_indexed:true},
        message: {type:String, es_indexed:true}
})

var clusterSchema = new Schema({
    name: String,
    info:{
        chatCount: Number,
        start: Number,
        end: Number,
        rooms: Array,
        senders: Array
    },
    chat: { type:[chatSchema], es_indexed:true }
})

clusterSchema.plugin(mongoosastic);

The "analyzer" attribute is not created or passed correctly to ElasticSearch. Here is what is created in ElasticSearch:

mappings: {
    cluster: {
        properties: {
            chat: {
                properties: {
                    message: {
                        type: string
                    }
                    time: {
                        type: long
                    }
                    _id: {
                        type: string
                    }
                    __v: {
                        type: long
                    }
                    cluster: {
                        type: string
                    }
                    user: {
                        type: string
                    }
                    room: {
                        type: string
                    }
                }
            }
            info: {
                properties: {
                    senders: {
                        type: string
                    }
                    start: {
                        type: long
                    }
                    chatCount: {
                        type: long
                    }
                    end: {
                        type: long
                    }
                    rooms: {
                        type: string
                    }
                }
            }
        }
    }
}

A few things to notice:

  • Although I haven't marked the multi-field "info" to be mapped, it is.
  • The "analyzer" attribute is not present on the room field in the chatSchema.
  • The cluster and time fields for the chatSchema (although not marked to be indexed) are being indexed (as well as the _id and __v that I'm assuming is used/managed by Mongoose/MongoDB)

Using Version: 0.2.6

@taterbase
Copy link
Owner

Awesome bug report! It's the holidays so I won't be looking at this immediately.

@saurabhghewari
Copy link

Please provide a detailed example of how to create a custom mapping using elasticals, mongoosastic.

@cwagner22
Copy link

I have the same issue (es_analyzer has no effect) and I'm not even using nested types....

@taterbase
Copy link
Owner

This issue has been moved to mongoosastic#5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants