本文整理汇总了Java中org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken类的典型用法代码示例。如果您正苦于以下问题:Java AnalyzeToken类的具体用法?Java AnalyzeToken怎么用?Java AnalyzeToken使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnalyzeToken类属于org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse包,在下文中一共展示了AnalyzeToken类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: assertIncludes
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken; //导入依赖的package包/类
private void assertIncludes(String input, List<String> expectedTokens, List<String> fields) throws ExecutionException, InterruptedException, IOException {
for (String field : fields) {
AnalyzeResponse response = client().admin().indices().prepareAnalyze(input).setField(field).setIndex("test").execute().get();
index("test", "type", "1", field, input);
// Verify all the expected tokens are in there
List<String> tokens = new ArrayList<String>();
for (AnalyzeToken token : response.getTokens()) {
assertFalse(StringUtils.isEmpty(token.getTerm()));
tokens.add(token.getTerm());
}
flush();
refresh();
for (String expectedToken : expectedTokens) {
assertTrue(tokens.contains(expectedToken));
SearchResponse sr = client().prepareSearch("test").setQuery(QueryBuilders.termQuery(field, expectedToken)).execute().actionGet();
assertThat(sr.getHits().getTotalHits(), is(1L));
sr = client().prepareSearch("test").setQuery(QueryBuilders.termQuery(field, "bogussearchterm")).execute().actionGet();
assertThat(sr.getHits().getTotalHits(), is(0l));
}
}
}
开发者ID:MyPureCloud,项目名称:elasticsearch-phone,代码行数:25,代码来源:PhoneTokenizerIntegrationTest.java
示例2: customAnalyzing
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken; //导入依赖的package包/类
public String customAnalyzing(String indexName, String analyzer, String str) throws InterruptedException, ExecutionException {
String[] strList = str.toLowerCase().split(",");
for (int i = 0; i < strList.length; i++) {
String tmp = "";
AnalyzeResponse r = client.admin().indices().prepareAnalyze(strList[i]).setIndex(indexName).setAnalyzer(analyzer).execute().get();
for (AnalyzeToken token : r.getTokens()) {
tmp += token.getTerm() + " ";
}
strList[i] = tmp.trim();
}
return String.join(",", strList);
}
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:13,代码来源:ESDriver.java
示例3: analyze
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken; //导入依赖的package包/类
/**
* 分词-无法分词则返回空集合
*
* @param analyzer
* @param str
* @return
*/
public static List<String> analyze(String analyzer, String str) {
AnalyzeResponse ar = null;
try {
AnalyzeRequest request = new AnalyzeRequest(str).analyzer(analyzer).index(
getCurrentValidIndex());
ar = ESClient.getClient().admin().indices().analyze(request).actionGet();
} catch (IndexMissingException e) {
if (!reLoad) {
synchronized (AnalyzeHelper.class) {
if (!reLoad) {
reLoad = true;
}
}
}
return analyze(analyzer, str);
}
if (ar == null || ar.getTokens() == null || ar.getTokens().size() < 1) {
return Lists.newArrayList();
}
List<String> analyzeTokens = Lists.newArrayList();
for (AnalyzeToken at : ar.getTokens()) {
analyzeTokens.add(at.getTerm());
}
return analyzeTokens;
}
开发者ID:hailin0,项目名称:es-service-parent,代码行数:35,代码来源:AnalyzeHelper.java
示例4: analyzeText
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken; //导入依赖的package包/类
@Override
public List<String> analyzeText(final String indexAliasName, final String analyzer, final String[] tokenFilters, final String text)
{
final List<String> tokens = new ArrayList<String>();
final AnalyzeRequestBuilder analyzeRequestBuilder = searchClientService.getClient().admin().indices().prepareAnalyze(text);
if (analyzer != null)
{
analyzeRequestBuilder.setIndex(indexAliasName);
}
if (analyzer != null)
{
analyzeRequestBuilder.setAnalyzer(analyzer);
}
if (tokenFilters != null)
{
analyzeRequestBuilder.setTokenFilters(tokenFilters);
}
logger.debug("Analyze request is text: {}, analyzer: {}, tokenfilters: {}", new Object[] { analyzeRequestBuilder.request().text(),
analyzeRequestBuilder.request().analyzer(), analyzeRequestBuilder.request().tokenFilters() });
final AnalyzeResponse analyzeResponse = analyzeRequestBuilder.get();
try
{
if (analyzeResponse != null)
{
logger.debug("Analyze response is : {}", analyzeResponse.toXContent(jsonBuilder().startObject(), ToXContent.EMPTY_PARAMS)
.prettyPrint().string());
}
}
catch (final IOException e)
{
logger.error("Error printing response.", e);
}
for (final AnalyzeToken analyzeToken : analyzeResponse.getTokens())
{
tokens.add(analyzeToken.getTerm());
}
return tokens;
}
开发者ID:jaibeermalik,项目名称:elasticsearch-akka,代码行数:39,代码来源:SetupIndexServiceImpl.java
示例5: analyzeText
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken; //导入依赖的package包/类
@Override
public List<String> analyzeText(final String indexAliasName,
final String analyzer, final String[] tokenFilters,
final String text) {
final List<String> tokens = new ArrayList<String>();
final AnalyzeRequestBuilder analyzeRequestBuilder = searchClientService
.getClient().admin().indices().prepareAnalyze(text);
if (analyzer != null) {
analyzeRequestBuilder.setIndex(indexAliasName);
}
if (analyzer != null) {
analyzeRequestBuilder.setAnalyzer(analyzer);
}
if (tokenFilters != null) {
analyzeRequestBuilder.setTokenFilters(tokenFilters);
}
logger.debug(
"Analyze request is text: {}, analyzer: {}, tokenfilters: {}",
new Object[] { analyzeRequestBuilder.request().text(),
analyzeRequestBuilder.request().analyzer(),
analyzeRequestBuilder.request().tokenFilters() });
final AnalyzeResponse analyzeResponse = analyzeRequestBuilder.get();
try {
if (analyzeResponse != null) {
logger.debug(
"Analyze response is : {}",
analyzeResponse
.toXContent(jsonBuilder().startObject(),
ToXContent.EMPTY_PARAMS).prettyPrint()
.string());
}
} catch (final IOException e) {
logger.error("Error printing response.", e);
}
for (final AnalyzeToken analyzeToken : analyzeResponse.getTokens()) {
tokens.add(analyzeToken.getTerm());
}
return tokens;
}
开发者ID:jaibeermalik,项目名称:searchanalytics-bigdata,代码行数:40,代码来源:SetupIndexServiceImpl.java
示例6: analyze
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken; //导入依赖的package包/类
default List<AnalyzeToken> analyze(@NonNull final String text, @NonNull final String analyzer) {
return prepareAnalyze(text).setAnalyzer(analyzer).get().getTokens();
}
开发者ID:thunken,项目名称:sandow,代码行数:4,代码来源:Index.java
示例7: analyzeText
import org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken; //导入依赖的package包/类
@Override
public List<String> analyzeText(String indexAliasName, String analyzer, String[] tokenFilters, String text)
{
List<String> tokens = new ArrayList<String>();
AnalyzeRequestBuilder analyzeRequestBuilder = searchClientService.getClient().admin().indices().prepareAnalyze(text);
if(analyzer !=null)
{
analyzeRequestBuilder.setIndex(indexAliasName);
}
if(analyzer !=null)
{
analyzeRequestBuilder.setAnalyzer(analyzer);
}
if(tokenFilters !=null)
{
analyzeRequestBuilder.setTokenFilters(tokenFilters);
}
logger.debug("Analyze request is text: {}, analyzer: {}, tokenfilters: {}", new Object[]{analyzeRequestBuilder.request().text(),
analyzeRequestBuilder.request().analyzer(),
analyzeRequestBuilder.request().tokenFilters()});
AnalyzeResponse analyzeResponse = analyzeRequestBuilder.get();
try
{
if(analyzeResponse != null)
{
logger.debug("Analyze response is : {}", analyzeResponse.toXContent(jsonBuilder().startObject(), ToXContent.EMPTY_PARAMS).prettyPrint().string());
}
} catch (IOException e)
{
logger.error("Error printing response.", e);
}
for (AnalyzeToken analyzeToken : analyzeResponse.getTokens())
{
tokens.add(analyzeToken.getTerm());
}
return tokens;
}
开发者ID:jaibeermalik,项目名称:elasticsearch-tutorial,代码行数:45,代码来源:SetupIndexServiceImpl.java
注:本文中的org.elasticsearch.action.admin.indices.analyze.AnalyzeResponse.AnalyzeToken类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论