Search in sources :

Example 1 with AnalyzeToken

use of org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken in project graylog2-server by Graylog2.

the class Messages method analyze.

public List<String> analyze(String string, String index, String analyzer) {
    final AnalyzeResponse response = c.admin().indices().prepareAnalyze(index, string).setAnalyzer(analyzer).get();
    final List<AnalyzeToken> tokens = response.getTokens();
    final List<String> terms = new ArrayList<>(tokens.size());
    for (AnalyzeToken token : tokens) {
        terms.add(token.getTerm());
    }
    return terms;
}
Also used : ArrayList(java.util.ArrayList) AnalyzeToken(org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken) AnalyzeResponse(org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse)

Aggregations

ArrayList (java.util.ArrayList)1 AnalyzeResponse (org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse)1 AnalyzeToken (org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken)1