Fielddata is disabled on text fields by default. Set fielddata=true on [xxx]

使用es查询的时候报错:
Fielddata is disabled on text fields by default. Set fielddata=true on [createTime] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.

java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [createTime] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory. Alternatively use a keyword field instead.
	at org.elasticsearch.index.mapper.TextFieldMapper$TextFieldType.fielddataBuilder(TextFieldMapper.java:779) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.index.fielddata.IndexFieldDataService.getForField(IndexFieldDataService.java:116) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.index.query.QueryShardContext.getForField(QueryShardContext.java:177) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.sort.FieldSortBuilder.build(FieldSortBuilder.java:353) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.sort.SortBuilder.buildSort(SortBuilder.java:153) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.SearchService.parseSource(SearchService.java:808) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.SearchService.createContext(SearchService.java:637) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.SearchService.createAndPutContext(SearchService.java:596) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.SearchService.executeDfsPhase(SearchService.java:324) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.SearchService.access$000(SearchService.java:126) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:310) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.SearchService$1.onResponse(SearchService.java:306) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.search.SearchService$4.doRun(SearchService.java:1107) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:41) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:751) ~[elasticsearch-6.8.7.jar:6.8.7]
	at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-6.8.7.jar:6.8.7]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) ~[na:1.8.0_241]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) ~[na:1.8.0_241]
	at java.lang.Thread.run(Thread.java:748) [na:1.8.0_241]

这个报错大概就是说使用的字段类型不可以排序(个人理解)
Fielddata is disabled on text fields by default. Set fielddata=true on [xxx]_第1张图片

最开始是使用createTime排序,但是发现报错。
后来又创建了个sortTime专门是排序使用的,设置的是long类型。解决了,不再报错了!

=================
欢迎大神指导,可以留言交流!

======================
本人原创文章,转载注明出入!

=================

你可能感兴趣的:(Bug记录)