Having a model class which is represtented like below,
class Search{
int id,
List<User> users;
}
class User{
int id,
String name;
}
For the mentioned class i would like to create mapping in elasticSearch and was wondering how to achieve the same.Googled everywhere but i couldn't get any, since i am very much new to elasticsearch.
I have pasted an incompleted index mapping below and requesting help to achieve the complete model mapping in elasticsearch.
PUT user_index
{
"mappings": {
"user_map": {
"properties": {
"id": {
"type": "integer"
}
}
}
}
}
Make users a nested
type and add the rest of the properties in there. Even, if you dont add properties of users, it would auto map them. Important thing is making users nested.
PUT user_index
{
"mappings":{
"users":{
"type":"nested",
"properties":{
"id":{
"type":"integer"
},
"name":{
"type":"text",
"fields":{
"keyword":{
"type":"keyword"
}
}
}
}
}
}
}