how to query fields using script that are under nested structure and are disabled for indexing ?
For example, my mappings:
PUT test
{
"mappings": {
"doc": {
"properties": {
"id": { "type": "keyword" },
"students": {
"type": "nested",
"properties": {
"firstName": { "type": "text" },
"lastName": { "type": "text" },
"subjects": {
"type" : "nested",
"enabled": false
}
}
}
}
}
}
}
PUT test/doc/1
{
"id": "test123",
"students": [
{
"firstName": "foo",
"lastName": "baz",
"subjects": [
{
"id": "1",
"name": "english"
}
]
},
{
"firstName": "foo",
"lastName": "bar",
"subjects": [
{
"id": "2",
"name": "science"
},
{
"id": "1",
"name": "english"
}
]
}
]
}
So for instance if subjects
is an array of objects with below structure:
{
"id": 1,
"name": "english"
},
{
"id": 2,
"name": "science"
}
....
How can I search for all documents with a particular subject's name? For example: Find all students data that has subject as "english". Do I need to use scripted queries? Any example on how to this on ES 6.2?