From the below, candidate Data structure How to write a query for getting records for the query candidate must have java experience > 1 and SQL experience > 2 and good to have angular experience > 1 but not must. Is it possible with the below data structure or if not how to structure that data
//Cand - 1
{
"canId": 1,
"skill": "Java",
"yearsOfExp": 2
},
{
"canId":1,
"skill": "SQL",
"yearsOfExp": 1
},
{
"canId": 1,
"skill": "Angular",
"yearsOfExp": 1
},
{
"canId": 1,
"skill": "AngularJS",
"yearsOfExp": 1
}
//Cand - 2
{
"canId": 2,
"skill": "Jr.Software Developer",
"yearsOfExp": 3
},
{
"canId":2,
"skill": "SQL",
"yearsOfExp": 2
},
{
"canId": 2,
"skill": "Angular",
"yearsOfExp": 2
},
{
"canId": 2,
"skill": "AngularJS",
"yearsOfExp": 5
}
Have modified the structure of data, and indexed the data (in the form of nested document). The nested type is a specialized version of the object data type that allows arrays of objects to be indexed in a way that they can be queried independently of each other.
Adding a working example with index data, mapping, search query, and search result.
Index Mapping:
Index Data:
Search Query:
Search Result: