Java 关键代码 HighlightBuilder highlightBuilder = new HighlightBuilder().field("productName").numOfFragments(0); List<String> productNames= hit.getHighlightField("productName"); if (productNames.size() > 0) { hit.getContent().setProductNames(productNames.get(0)); } number_of_fragments:要返回的最大片段数。如果分片数设置为0,则不返回分片。相反,整个字段内容都会突出显示并返回。 number_of_fragments: The maximum number of fragments to return. If the number of fragments is set to 0, no fragments are returned. Instead, the entire field contents are highlighted and returned.