When I use this script
doc['reqBody'].length
And I go to "Discover" page to show that field, and this happened.
{
"took": 201,
"timed_out": false,
"num_reduce_phases": 92,
"_shards": {
"total": 672,
"successful": 656,
"skipped": 306,
"failed": 16,
"failures": [
{
"shard": 2,
"index": "cpx-request-stream-log-ms-current-2020.10.28",
"node": "71QJmoFbRE6gUqt32ulOMg",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:763)",
"org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:116)",
"org.elasticsearch.index.query.QueryShardContext.lambda$lookup$0(QueryShardContext.java:330)",
"org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:97)",
"org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:94)",
"java.base/java.security.AccessController.doPrivileged(AccessController.java:312)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
"doc['reqBody'].length",
" ^---- HERE"
],
"script": "doc['reqBody'].length",
"lang": "painless",
"position": {
"offset": 4,
"start": 0,
"end": 21
},
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [reqBody] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
},
{
"shard": 6,
"index": "cpx-request-stream-log-ms-current-2020.10.27",
"node": "71QJmoFbRE6gUqt32ulOMg",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:763)",
"org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:116)",
"org.elasticsearch.index.query.QueryShardContext.lambda$lookup$0(QueryShardContext.java:330)",
"org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:97)",
"org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:94)",
"java.base/java.security.AccessController.doPrivileged(AccessController.java:312)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
"doc['reqBody'].length",
" ^---- HERE"
],
"script": "doc['reqBody'].length",
"lang": "painless",
"position": {
"offset": 4,
"start": 0,
"end": 21
},
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [reqBody] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
},
{
"shard": 11,
"index": "cpx-request-stream-log-ms-current-2020.10.26",
"node": "IY2aR2zaQ2Wp1HdX2EXs4w",
"reason": {
"type": "script_exception",
"reason": "runtime error",
"script_stack": [
"org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:763)",
"org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:116)",
"org.elasticsearch.index.query.QueryShardContext.lambda$lookup$0(QueryShardContext.java:330)",
"org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:97)",
"org.elasticsearch.search.lookup.LeafDocLookup$1.run(LeafDocLookup.java:94)",
"java.base/java.security.AccessController.doPrivileged(AccessController.java:312)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:94)",
"org.elasticsearch.search.lookup.LeafDocLookup.get(LeafDocLookup.java:41)",
"doc['reqBody'].length",
" ^---- HERE"
],
"script": "doc['reqBody'].length",
"lang": "painless",
"position": {
"offset": 4,
"start": 0,
"end": 21
},
"caused_by": {
"type": "illegal_argument_exception",
"reason": "Text fields are not optimised for operations that require per-document field data like aggregations and sorting, so these operations are disabled by default. Please use a keyword field instead. Alternatively, set fielddata=true on [reqBody] in order to load field data by uninverting the inverted index. Note that this can use significant memory."
}
}
}
]
},
"hits": {
"total": 23,
"max_score": null,
"hits": []
},
"aggregations": {
"2": {
"buckets": [
{
"key_as_string": "2020-10-26T09:00:00.000+07:00",
"key": 1603677600000,
"doc_count": 3
},
{
"key_as_string": "2020-10-26T15:00:00.000+07:00",
"key": 1603699200000,
"doc_count": 6
},
{
"key_as_string": "2020-10-27T09:00:00.000+07:00",
"key": 1603764000000,
"doc_count": 2
},
{
"key_as_string": "2020-10-27T12:00:00.000+07:00",
"key": 1603774800000,
"doc_count": 6
},
{
"key_as_string": "2020-10-28T09:00:00.000+07:00",
"key": 1603850400000,
"doc_count": 4
},
{
"key_as_string": "2020-10-28T12:00:00.000+07:00",
"key": 1603861200000,
"doc_count": 1
},
{
"key_as_string": "2020-10-28T15:00:00.000+07:00",
"key": 1603872000000,
"doc_count": 1
}
]
}
}
}
What I need to fix it ?
Sample data of 'reqBody'
{"masterStagingId":"PAYROLL72e6972d84b047af88e62258dbaea998","paymentProductId":"PAYROLL","batchReferenceId":"PAY201028df78fa27a86","scheduleMainId":null,"scheduleDetailId":null,"isLastSchedule":null,"batchStatus":"PROCESSING","isBatchStatusFinal":false,"isDebited":false}