How to use dynamic mapping with javascript client putmapping

(Bmarker1) #1

I can't seem to figure out how to use dynamic mapping using the javascript client. My goal is to convert everything into a string. I have tried multiple things, but the documentation lacks an example. I've read that it needs to be in a body, I've read I don't need the 'mappings' field if I'm using .putMapping (I've tried both). I get an error index not created if I try to map before the index goes through .create function. But when I create it, the mapping is already set, so I'm confused. This is one thing I have tried (I've tried before the create and outside of the create function): HELP please!


event. has a bunch of other data

event.mappings = {
            "event": {
                "dynamic_templates": [
                      "en": {
                        "match": "*",
                        "mapping": {
                          "type": "string"


 esClientLookup.getClient( function(esClient) {
                index: 'timeline-2015-10-24',
                type: 'event',
                body: event
            }, function (error, response) {
                if (error) {
                    logger.log(logger.SEVERITY.ERROR, 'acceptEvent elasticsearch create failed with: '+ error + " req:" + JSON.stringify(event));
                    res.status(500).send('Error saving document');
                } else {
                    esClient.indices.putMapping({index:'timeline-2015-10-24', type:'event', body:event});

(system) #2