WE are using Spring-boot-Elasticsearch to create a index into elastic from java. We are facing a issue describe below:
Entity:
@Document(indexName = "user")
@Setting(settingPath = "/settings/lower-case-normalizer.json")
public class UserLoginEventsEntity {
@Id
@Field(type = FieldType.Keyword)
private String id;
@MultiField(mainField = @Field(type = FieldType.Text, fielddata=true), otherFields = {@InnerField(suffix = "raw", type = FieldType.Keyword, normalizer = "lower-case-normalizer") })
private String user;
}
Below is the mapping looks like,
{
"properties": {
"_class": {
"type": "keyword",
"index": false,
"doc_values": false
},
"id": {
"type": "keyword"
},
"user": {
"type": "text",
"fields": {
"raw": {
"type": "keyword",
"normalizer": "lower-case-normalizer"
}
},
"fielddata": true
}
}
}
lower-case-normalizer.json:
{
"index": {
"number_of_shards": 4,
"analysis": {
"normalizer": {
"lower-case-normalizer": {
"type": "custom",
"char_filter": ,
"filter": ["lowercase", "asciifolding"]
}
}
}
}
}
Added some data to the index using JAVA API calls, again tried to add the below filed in the same index,
@MultiField(mainField = @Field(type = FieldType.Text, fielddata=true), otherFields = {@InnerField(suffix = "raw", type = FieldType.Keyword, normalizer = "lower-case-normalizer") })
private String name;
And restartd the java application, Below is the mapping looks like:
{
"properties": {
"_class": {
"type": "keyword",
"index": false,
"doc_values": false
},
"id": {
"type": "keyword"
},
"user": {
"type": "text",
"fields": {
"raw": {
"type": "keyword",
"normalizer": "lower-case-normalizer"
}
},
"fielddata": true
},
"sample3" : {
** "type" : "text",**
** "fields" : {**
** "keyword" : {**
** "type" : "keyword",**
** "ignore_above" : 256**
** }**
** }**
** }**
}
}
But excepted mapping is should be below:
{
"properties": {
"_class": {
"type": "keyword",
"index": false,
"doc_values": false
},
"id": {
"type": "keyword"
},
"user": {
"type": "text",
"fields": {
"raw": {
"type": "keyword",
"normalizer": "lower-case-normalizer"
}
},
"fielddata": true
},
"sample3" : {
** "type" : "text",**
** "fields" : {**
** "raw" : {**
** "type" : "keyword",**
** "normalizer": "lower-case-normalizer"**
** }**
** },**
** "fielddata": true**
** }**
}
}
But the highlighted part is different.
We are currently using Elasticsearch version 7.17.5 and spring-data-elasticsearch version 4.4.2. , Spring boot 2.7.1 and java 1.8
Elastic running as a docker container.
Has anyone else encountered a similar issue? how to resolve this one?