TermsAggregationBuilder xxslAggregation = AggregationBuilderstermsxxslfieldhpzlinclude小型; TermsAggregationBuilder dxslAggregation = AggregationBuilderstermsdxslfieldhpzlinclude大型;include报错
The issue is with the usage of the .include() method. The .include() method is used to specify the terms that should be included in the aggregation results. However, it seems like the syntax you are using is incorrect.
To include terms that match a specific pattern, you can use the .includePattern() method instead. Here's the correct way to use it:
TermsAggregationBuilder xxslAggregation = AggregationBuilders.terms("xxsl").field("hpzl").includePattern(".*小型.*");
TermsAggregationBuilder dxslAggregation = AggregationBuilders.terms("dxsl").field("hpzl").includePattern(".*大型.*");
In this example, the includePattern() method is used to specify a regular expression pattern that matches terms containing "小型" or "大型" respectively. The .* before and after the keyword ensures that any characters can appear before and after the keyword in the terms.
Make sure to import the necessary classes for the AggregationBuilders and TermsAggregationBuilder if you haven't already done so
原文地址: http://www.cveoy.top/t/topic/iFf0 著作权归作者所有。请勿转载和采集!