无法在映射Elasticsearch 6.1.2中插入规范化程序

时间:2018-02-28 13:47:24

标签: java elasticsearch mapping normalization lowercase

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

索引设置:

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尝试它时我遵循异常

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。

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:0)

            //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) {
            }