I'm currently parsing text from internal résumés in my company. The goal is to index everything in elasticsearch to perform search on them.
for the moment I have the following JSON document with no mapping defined :
Each coworker has a list of project with the client name
{
name: "Jean Wisser"
position: "Junior Developer"
"projects": [
{
"client": "SutrixMedia",
"missions": [
"Responsible for the quality on time and within budget",
"Writing specs, testing,..."
],
"technologies": "JIRA/Mantis/Adobe CQ5 (AEM)"
},
{
"client": "Société Générale",
"missions": [
" Writing test cases and scenarios",
" UAT"
],
"technologies": "HP QTP/QC"
}
]
}
The 2 main questions we would like to answer are :
- Which coworker has already worked in this company ?
- Which client use this technology ?
The first question is really easy to answer, for example:
Projects.client="SutrixMedia
" returns me the right resume.
But how can I answer to the second one ?
I would like to make a query like this : Projects.technologies="HP QTP/QC"
and the answer would be only the client name ("Société Générale" in this case) and NOT the entire document.
Is it possible to get this answer by defining a mapping with nested type ? Or should I go for a parent/child mapping ?
Yes, indeed, that's possible with ES 1.5.* if you map
projects
asnested
type and then retrieve nestedinner_hits
.So here goes the mapping for your sample document above:
Then, you can index your sample document from above:
Finally, with the following query which only retrieves the nested
inner_hits
you can retrieve only the nested object that matchesProjects.technologies="HP QTP/QC"
which yields only the client name instead of the whole matching document: