I create index with nested field
{
"chat": {
"aliases": {},
"mappings": {
"properties": {
"dataset_id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"messages": {
"properties": {
"chat_id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"content": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"content_id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"created_at": {
"type": "date"
},
"dialog_id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"id": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"index": {
"type": "long"
},
"role": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"row_number": {
"type": "long"
},
"trainable": {
"type": "boolean"
}
}
}
}
},
"settings": {
"index": {
"routing": {
"allocation": {
"include": {
"_tier_preference": "data_content"
}
}
},
"number_of_shards": "1",
"provided_name": "chat",
"creation_date": "1751372790348",
"number_of_replicas": "1",
"uuid": "67iZTI7IT8ehAqr7k7ZetA",
"version": {
"created": "9009000"
}
}
}
}
}```
and trying to search messages from user
{
"query": {
"nested": {
"path": "messages",
"query": {
"bool": {
"must": [
{
"match": {
"messages.role.keyword": "user"
}
}
]
}
}
}
}
}```
but I've got error
{
"error": {
"root_cause": [
{
"type": "query_shard_exception",
"reason": "failed to create query: [nested] failed to find nested object under path [messages]",
"index_uuid": "67iZTI7IT8ehAqr7k7ZetA",
"index": "chat"
}
],
"type": "search_phase_execution_exception",
"reason": "all shards failed",
"phase": "query",
"grouped": true,
"failed_shards": [
{
"shard": 0,
"index": "chat",
"node": "lwXfQmtGQlu5e8aDxK1xYw",
"reason": {
"type": "query_shard_exception",
"reason": "failed to create query: [nested] failed to find nested object under path [messages]",
"index_uuid": "67iZTI7IT8ehAqr7k7ZetA",
"index": "chat",
"caused_by": {
"type": "illegal_state_exception",
"reason": "[nested] failed to find nested object under path [messages]"
}
}
}
]
},
"status": 400
}