无法在映射Elasticsearch 6.1.2中插入规范化器 [英] Not able to insert normalizer in mapping Elasticsearch 6.1.2

查看:219
本文介绍了无法在映射Elasticsearch 6.1.2中插入规范化器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经尝试在索引中插入以下映射以支持搜索功能.

I had trying to insert the following mapping in the the index to support the search feature.

索引设置:

url: PUT http:/localhost:9200/indexname

{
    "settings": {
        "analysis": {
            "normalizer": {
                "my_normalizer": {
                    "type": "custom",
                    "filter": ["lowercase"]
                }
            }
        }
    }
}

映射:

url: PUT http:/localhost:9200/indexname/typename/_mapping

{
    "org-5-table": {
        "properties": {

            "GroupName": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "lowcase": {
                        "type": "keyword",
                        "normalizer": "my_normalizer"
                    }
                }
            },
            "Createdby": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "lowcase": {
                        "type": "keyword",
                        "normalizer": "my_normalizer"
                    }
                }
            },
            "GroupUser": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "lowcase": {
                        "type": "keyword",
                        "normalizer": "my_normalizer"
                    }
                }
            },
            "UpdatedDateTime": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "lowcase": {
                        "type": "keyword",
                        "normalizer": "my_normalizer"
                    }
                }
            },
            "GroupMessage": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "lowcase": {
                        "type": "keyword",
                        "normalizer": "my_normalizer"
                    }
                }
            },
            "CreatedDateTime": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "lowcase": {
                        "type": "keyword",
                        "normalizer": "my_normalizer"
                    }
                }
            },
            "GroupId": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "lowcase": {
                        "type": "keyword",
                        "normalizer": "my_normalizer"
                    }
                }
            },
            "status": {
                "type": "text",
                "fielddata": true,
                "fields": {
                    "keyword": {
                        "type": "keyword"
                    },
                    "lowcase": {
                        "type": "keyword",
                        "normalizer": "my_normalizer"
                    }
                }
            }
        }
    }
}

当我尝试通过浏览器映射插入此对象时,会正确插入,但是当我通过elasticsearch java api尝试插入时,我会遵循Exception

when I tried to insert this through browser mapping are inserted correctly but when I tried it through elasticsearch java api I am following Exception

Elasticsearch exception [type=illegal_argument_exception, reason=unknown setting [index.settings.analysis.normalizer.my_normalizer.filter] please check that any required plugins are installed, or check the breaking changes documentation for removed settings]

这是我正在使用的代码

    CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
    createIndexRequest.settings(settings.toString(), XContentType.JSON);
    createIndexRequest.mapping(typeName, mapping.toString(),XContentType.JSON);
    client.indices().create(createIndexRequest, header).isAcknowledged()

Elasticsearch 6.1.2.

Elasticsearch 6.1.2.

我们非常感谢您的帮助.

Any help is really appreciated.

推荐答案

            //to put setting in the index   
             StringEntity settingEntity= new StringEntity(settings.toString(), ContentType.APPLICATION_JSON);
            int statuscode2 = client.getLowLevelClient().performRequest("PUT", "/" + indexName , Collections.<String, String>emptyMap(), settingEntity).getStatusLine().getStatusCode();

            if(200 == statuscode2) {
            }


            //to put mapping in the index
            StringEntity mappingEntity = new StringEntity(mapping.toString(), ContentType.APPLICATION_JSON);
            int statuscode3 = client.getLowLevelClient().performRequest("PUT", "/" + indexName + "/" + typeName + "/" + "_mapping", Collections.<String, String>emptyMap(), mappingEntity).getStatusLine().getStatusCode();

            if(200 == statuscode3) {
            }

这篇关于无法在映射Elasticsearch 6.1.2中插入规范化器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆