问题
I had trying to insert the following mapping in the the index to support the search feature.
Index setting :
url: PUT http:/localhost:9200/indexname
{
"settings": {
"analysis": {
"normalizer": {
"my_normalizer": {
"type": "custom",
"filter": ["lowercase"]
}
}
}
}
}
Mappings :
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"
}
}
}
}
}
}
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]
This is the code I am using
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.
Any help is really appreciated.
回答1:
//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) {
}
来源:https://stackoverflow.com/questions/49031086/not-able-to-insert-normalizer-in-mapping-elasticsearch-6-1-2