Hi,
I have a quite complex model to put as a document .
Here is the mapping
{
"id" : {"type" : "integer" },
"public_name": {"type" : "string" ,"store" : "no", "index":"no" },
"description": {"type" : "string" ,"store" : "no", "index":"analyzed" },
"website_url": {"type" : "string" ,"store" : "no", "index":"no" },
"overall_rating": {"type" : "float" },
"plan_id": {"type" : "integer" },
"city": {"type" : "string" ,"store" : "yes", "index":"analyzed" },
"zipcode": {"type" : "string" ,"store" : "yes", "index":"analyzed" },
"state": {"type" : "string" ,"store" : "yes", "index":"analyzed" },
"country": {"type" : "string" ,"store" : "yes", "index":"analyzed" },
"location":{"type" : "geo_point" , "lat_lon" : true},
"created": {"type" : "date" ,"format" : "YYYY-MM-dd HH:mm:ss" },
"profile_type_3" : {
"type" : "object",
"properties" : {
"profile_roles" : {
"properties" : {
"role_id" : {"type" : "integer","store" : "yes",
"index":"analyzed"},
"industry_id" : {"type" : "integer"},
"description" : {"type" : "string","store" : "yes",
"index":"analyzed"}
"skills" : {
"properties" : {
"skill_id" : {"type" : "integer", "store" : "yes"},
"skill_name" : {"type" : "string","store" : "yes",
"index":"analyzed"},
"experience_level_id" : {"type" : "integer","store"
: "yes"}
}
},
"terms" : {
"properties" : {
"term_id" : {"type" : "integer","store" : "yes" },
"term_name" : {"type" : "string","store" : "yes" }
}
}
}
}
}
},
"profile_type_2" : {
"type" : "object",
"properties" : {
"profile_roles" : {
"properties" : {
"role_id" : {"type" : "integer","store" : "yes" },
"role_name" : {"type" : "string","store" : "yes" },
"industry_id" : {"type" : "integer"},
"description" : {"type" : "string","store" : "yes",
"index":"analyzed"},
"skills" : {
"properties" : {
"skill_id" : {"type" : "integer","store" : "yes",
"index":"analyzed"},
"skill_name" : {"type" : "string","store" : "yes",
"index":"analyzed"},
"experience_level_id" : {"type" : "integer","store" :
"yes", "index":"analyzed"},
"experience_level_name" : {"type" : "string"}
}
}
}
}
}
}
}
Each profile_type_* contains many profile_roles (as array) and each
profiles_roles contains many skills (as array) and terms (as array)
So data could look like this
.....
"profile_type_3" : {
"profile_roles" : {
{
"role_id" : 1,
"industry_id" : 1,
"description" : "some text"
"skills" : {
{
"skill_id" : 10,
"skill_name" : "PHP",
"experience_level_id" : 1
},
{
"skill_id" : 12,
"skill_name" : "PYTHON",
"experience_level_id" : 3
}
}
"terms" : {
{
"term_id" : 1,
"term_name" : "some text"
},
{
"term_id" : 2,
"term_name" : "some text"
},
}
},
{
"role_id" : 2,
"industry_id" : 13,
"description" : "some text"
"skills" : {
{
"skill_id" : 10,
"skill_name" : "PHP",
"experience_level_id" : 1
},
{
"skill_id" : 12,
"skill_name" : "PYTHON",
"experience_level_id" : 3
}
}
"terms" : {
{
"term_id" : 1,
"term_name" : "some text"
},
{
"term_id" : 2,
"term_name" : "some text"
},
}
},
}
}
So a profile_type_* could have many profile_roles , a rofile_role could
have many skills and terms
so now if need to get document that have a profile_roles with role_id = 1
and a skill_id = 12 ( within the role_id = 1) and experience level >= 2
how can i achieve this ? i read about nested object but here i have nested
nested object profile -> profiles_roles -> skills
For skill I think about creating some kind of tuple field like for example
skills = [ "10:1", "12:3" ] where the first sohuld be the id and the
second the experience_id but how to do it for profile_roles aswell ? by
creating some kind of hash like this : roles = [ "1:10:1", "1:12:13" ] ?
If someone could help to understand the best way to achieve this it will be
really great, thanks.
--