Versions (relevant - OpenSearch/Dashboard/Server OS/Browser): 2.8
Describe the issue:
No results found when I filter by extraFields.field_id.keyword
"nested": {
"path": "extraFields",
"query": {
"bool": {
"must": [
{ "term": { "extraFields.field_id.keyword": 12 } }
]
}
}
}
If I filter by extraFields.field_id
I get this exception:
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: Cannot search on field [extraFields.field_id] since it is not indexed."
}
],
If search for extraFields.data
using the match
clause it returns the right record. Additionally, if I filter by age.keyword
it returns the right records too. The issue is using the nested field extraFields.field_id
.
Is it mandatory that all nested fields are indexed as text type ("type": "text"
)?
Configuration:
{
"settings": {
"index": {
"number_of_shards": 1,
"number_of_replicas": 2
}
},
"mappings": {
"properties": {
"extraFields": {
"type": "nested",
"properties": {
"id": {
"type": "keyword",
"index": false
},
"data": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
},
"field_id": {
"type": "keyword"
}
}
},
"age": {
"type": "keyword"
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword"
}
}
}
}
}
}
Relevant Logs or Screenshots: