elasticsearch 5.2.2 java addsort有错误

时间:2017-03-27 09:02:35

标签: elasticsearch

当我使用elasticsearch java api对我的文档进行排序时,es有错误:

Caused by: java.lang.IllegalArgumentException: Fielddata is disabled on text fields by default. Set fielddata=true on [namespaceName] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.

我的代码分类如下:

SortBuilder sortBuilder = SortBuilders.fieldSort(sortField)
                .order(SortOrder.valueOf(order.toUpperCase()));
SearchRequestBuilder srb1 = client.prepareSearch()
                .setQuery(qb).setIndices(indexName)
                .setTypes(type).addSort(sortBuilder);

我想知道如何通过java api设置fielddata = true。

0 个答案:

没有答案