0

When I am doing custom mapping using kibana its working properly but when I am doing the same thing in my node program its showing mapper parsing exception. Reason:Root mapping definition has unsupported parameters:tags(custom mapping name) Because in kibana i am able to use include_type_name =true but in my node program it is not available.

        var name = req.body.templatename;
        var index_patterns = req.body.index_patterns;
        console.log(index_patterns);
        const opts: IndicesPutTemplateParams = {
            name: name,
            body: {
                index_patterns: [index_patterns],
                settings: {
                    analysis: {
                        filter: {
                            autocomplete_filter: {
                                type: "edge_ngram",
                                min_gram: 1,
                                max_gram: 20
                            }
                        },
                        analyzer: {
                            autocomplete: {
                                type: "custom",
                                tokenizer: "standard",
                                filter: [
                                    "lowercase",
                                    "autocomplete_filter"
                                ]
                            }
                        }
                    }
                },
                mappings: {
                    tags: {
                        properties: {
                            name: {
                                type: "text",
                                analyzer: "autocomplete",
                                search_analyzer: "standard"
                            },
                            normalized: {
                                type: "text"
                            },
                            status: {
                                type: "text"
                            },
                            createdat: {
                                type: "date"
                            },
                            updatedat: {
                                type: "date"
                            }
                        }
                    }
                }

            }
        }
        try {
            esClient.indices.putTemplate(opts).then((data: any) => {
               return res.json({
                   data
               });
                console.log(data);
              }).catch((err: any) => {
                console.log(err);
                res.status(500).json({
                    err
                })
            });     
        } catch (error) {
            res.status(500).json({
                error
            })
        }
    }```

1 Answer 1

1

As Per documentation you need to give include_type_name as

client.indices.putTemplate({
  name: string,
  include_type_name: boolean,  ---> 
  order: number,
  create: boolean,
  timeout: string,
  master_timeout: string,
  flat_settings: boolean,
  body: object                -> mapping object
})

Or you can drop mapping name tags from mapping

  mappings: {
                    tags: {  ---> remove
Sign up to request clarification or add additional context in comments.

4 Comments

This is not useful.
What is the issue?. Please elaborate
when i am using include_type_name in my typescript file its showing error because there is no include_type_name parameter in putmapping.
You can remove include type name. Mapping structure is like below mappings: { properties:{}}. If you are giving include type name then you need to define mapping like below mappings: { “type_name”:{ “properties”:{}}}. Type name is only for backward compatibility, you don’t need to give it in mapping or command

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.