0
我正在從ES 1.7遷移到5.2並重構以下代碼。Elasticsearch Java API遷移形式TermsFacetBuilder with AggregationBuilders
ES 1.7
public void prepare(final SearchRequestBuilder searchRequestBuilder) {
final TermsFacetBuilder labelsFacet = FacetBuilders
.termsFacet("labels")
.field("labels");
searchRequestBuilder.addFacet(labelsFacet);
searchRequestBuilder.setFrom(start);
searchRequestBuilder.setSize(size);
}
與ES 5.2
public void prepare(final SearchRequestBuilder searchRequestBuilder) {
TermsAggregationBuilder aggregation = AggregationBuilders.terms("labels").field("labels");
searchRequestBuilder.addAggregation(aggregation);
searchRequestBuilder.setFrom(start);
searchRequestBuilder.setSize(size);
}
當我火了搜索查詢,我收到以下異常
nested: IllegalArgumentException[Fielddata is disabled on text fields by default. Set fielddata=true on [labels] in order to load fielddata in memory by uninverting the inverted index. Note that this can however use significant memory.]
我也試着設置上SearchRequestBuilder的fieldDocValue但沒有運氣。
您是否在標籤上設置了fielddata = true,如錯誤消息所示? – Jeremy
@Jeremy,我們如何設置它? – Santosh