use of co.elastic.clients.elasticsearch.indices.AnalyzeResponse in project core-ng-project by neowu.
the class ElasticSearchTypeImpl method analyze.
@Override
public List<String> analyze(AnalyzeRequest request) {
var watch = new StopWatch();
String index = request.index == null ? this.index : request.index;
try {
AnalyzeResponse response = elasticSearch.client.indices().analyze(builder -> builder.index(index).analyzer(request.analyzer).text(request.text));
return response.tokens().stream().map(AnalyzeToken::token).toList();
} catch (IOException e) {
throw new UncheckedIOException(e);
} catch (ElasticsearchException e) {
throw elasticSearch.searchException(e);
} finally {
long elapsed = watch.elapsed();
ActionLogContext.track("elasticsearch", elapsed);
logger.debug("analyze, index={}, analyzer={}, elapsed={}", index, request.analyzer, elapsed);
checkSlowOperation(elapsed);
}
}
Aggregations