如何使用java API对弹性搜索中的文本进行分析? [英] how to analyze text in elasticsearch using java api?
问题描述
任何人都知道如何使用java API或其他方式在弹性搜索中分析文本,而不是请求宁静的api?
感谢任何人可能会帮助想法,提示,资源等。
使用文档中的示例(文本这是一个测试)正在使用标准
分析器进行分析),这里是一个例子可以使用Java API完成相同的分析:
TransportClient client = new TransportClient();
AnalyzeRequest request =(new AnalyzeRequest(this is a test))。analyzer(standard);
列表< AnalyzeResponse.AnalyzeToken> tokens = client.admin()。indices()。analyze(request).actionGet()。getTokens();
for(AnalyzeResponse.AnalyzeToken token:tokens)
{
//对每个令牌执行某些操作...
}
希望这有帮助!
I use Elasticsearch 1.7.4 and its java API.Currently, I want to count the top 10 high frequency searching words by user. So I have to record the words of query text which user type to search, and before recording the words I have to analyze the query text. I find the restful way to analyze text as the link says, but I can't find the api in TransportClient.
do anyone know how to analyze text in elasticsearch using java api or some other way rather than requesting the restful api?
Thanks to anyone who might help with ideas, tips, resources, etc.
Using the example from the documentation (where the text "this is a test" is being analyzed using the standard
analyzer), here is an example of how one might accomplish the same analysis using the Java API:
TransportClient client = new TransportClient();
AnalyzeRequest request = (new AnalyzeRequest("this is a test")).analyzer("standard");
List<AnalyzeResponse.AnalyzeToken> tokens = client.admin().indices().analyze(request).actionGet().getTokens();
for (AnalyzeResponse.AnalyzeToken token : tokens)
{
// do something with each token...
}
Hope this helps!
这篇关于如何使用java API对弹性搜索中的文本进行分析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!