es java api 设置index mapping 报错 mapping source must be pairs of fieldnames and properties definition.
Posted bigwrite
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了es java api 设置index mapping 报错 mapping source must be pairs of fieldnames and properties definition.相关的知识,希望对你有一定的参考价值。
java.lang.IllegalArgumentException: mapping source must be pairs of fieldnames and properties definition.
从es官网找到的
request.mapping("_doc", "\\n" + " \\"_doc\\": \\n" + " \\"properties\\": \\n" + " \\"message\\": \\n" + " \\"type\\": \\"text\\"\\n" + " \\n" + " \\n" + " \\n" + "", XContentType.JSON);
不生效并报错
查看源码,发现mapping的第二个参数,要求必须为 %2==0,改为
request.mapping("_doc", "datetime", "type=date");
多个参数
request.mapping("_doc", "datetime", "type=date", "string", "type=text");
以上是关于es java api 设置index mapping 报错 mapping source must be pairs of fieldnames and properties definition.的主要内容,如果未能解决你的问题,请参考以下文章