@SneakyThrows
public List<String> analyze(String text, String analyzer){
AnalyzeRequest request = AnalyzeRequest.withIndexAnalyzer("索引名称",analyzer, text);
AnalyzeResponse response = restHighLevelClient.indices().analyze(request, RequestOptions.DEFAULT);
List<String> words = new ArrayList<>();
List<AnalyzeResponse.AnalyzeToken> tokens = response.getTokens();
for (AnalyzeResponse.AnalyzeToken token : tokens) {
String term = token.getTerm();
words.add(term);
}
return words;
}
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交