• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java PercolateResponse类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.elasticsearch.action.percolate.PercolateResponse的典型用法代码示例。如果您正苦于以下问题:Java PercolateResponse类的具体用法?Java PercolateResponse怎么用?Java PercolateResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PercolateResponse类属于org.elasticsearch.action.percolate包,在下文中一共展示了PercolateResponse类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: percolate

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
public PercolateResponse percolate(String[] indexNames, String documentType, Object tuple)
{
  XContentBuilder docBuilder;
  try {

    docBuilder = XContentFactory.jsonBuilder().startObject();
    docBuilder.field("doc").startObject(); //This is needed to designate the document
    docBuilder.field("content", tuple);
    docBuilder.endObject(); //End of the doc field
    docBuilder.endObject();//End of the JSON root object

    return client.preparePercolate().setIndices(indexNames)
        .setDocumentType(documentType)
        .setSource(docBuilder)
        .execute().actionGet();
  } catch (IOException e) {
    DTThrowable.rethrow(e);
  }
  return null;
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:21,代码来源:ElasticSearchPercolatorStore.java


示例2: fetchMatchingAlertTerms

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
ArrayList<String> fetchMatchingAlertTerms(AbstractPost post){
    ArrayList<String> matchingTerms = new ArrayList<String>();
    try {
        XContentBuilder docBuilder = XContentFactory.jsonBuilder().startObject();
        docBuilder.field("doc").startObject(); //This is needed to designate the document
        docBuilder.field(ALERT_FIELD, post.text);
        docBuilder.endObject(); //End of the doc field
        docBuilder.endObject(); //End of the JSON root object
        //Percolate
        PercolateResponse response = ElasticsearchConnectionManager.getClient().preparePercolate()
                .setIndices(ALERT_INDEX)
                .setDocumentType(post.getType())
                .setSource(docBuilder).execute().actionGet();
        //Iterate over the results and add the registered alert term
        for(PercolateResponse.Match match : response) {
            matchingTerms.add(match.getId().toString());
        }
    } catch (IOException e) {
        System.out.println("Error! Can't check if a post is matching a percolator alert");
        e.printStackTrace();
    }
    return matchingTerms;
}
 
开发者ID:txtData,项目名称:socialradar,代码行数:24,代码来源:AlertManager.java


示例3: process

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
@Override
public void process(Object tuple)
{

  PercolateResponse response = store.percolate(new String[] {indexName}, documentType, tuple);
  outputPort.emit(response);
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:8,代码来源:ElasticSearchPercolatorOperator.java


示例4: percolate

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
@Override
public List<PercolateQuery> percolate(List<Document> docs) {
    final Stopwatch watch = LoggingUtils.createStopWatch();
    final List<PercolateQuery> results = new ArrayList<>();
    final MultiPercolateRequestBuilder multiPercolate = client.prepareMultiPercolate();

    for (final Document doc : docs) {
        if (doc.getPercolate() != null) {
            multiPercolate.add(
                    new PercolateRequestBuilder(client).setDocumentType(doc.get_type())
                            .setSize(doc.getPercolate().getMaxMatches())
                            .setPercolateDoc(new PercolateSourceBuilder.DocBuilder().setDoc(doc.get_jsonObject())));
        }
    }

    final MultiPercolateResponse.Item[] responses = multiPercolate.get().getItems();
    for (final MultiPercolateResponse.Item response : responses) {
        if (!response.isFailure()) {
            for (final PercolateResponse.Match match : response.getResponse().getMatches()) {
                results.add(new PercolateQuery().setId(match.getId().toString()));
            }
        }
    }

    LoggingUtils.stopAndLogStopWatch(logger, watch, "Percolate");

    return results;
}
 
开发者ID:ezbake,项目名称:ezelastic,代码行数:29,代码来源:ElasticClient.java


示例5: toXContent

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
@Override
protected XContentBuilder toXContent(PercolateRequest request, PercolateResponse response, XContentBuilder builder) throws IOException {
    builder.startObject();
    builder.field(Fields.OK, true);
    builder.startArray(Fields.MATCHES);
    for (String match : response) {
        builder.value(match);
    }
    builder.endArray();
    builder.endObject();
    return builder;
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:13,代码来源:PercolateRequestBuilder.java


示例6: testPercolate

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
private void testPercolate() throws IOException {

        // This is the query we're registering in the percolator
        QueryBuilder qb = termQuery("content", "amazing");

        // Index the query = register it in the percolator
        client.prepareIndex("_percolator", "myIndexName", "myDesignatedQueryName") //
                .setSource(qb.buildAsBytes()) //
                .setRefresh(true) // Needed when the query shall be available
                                  // immediately
                .execute().actionGet();

        // Build a document to check against the percolator
        XContentBuilder docBuilder = jsonBuilder().startObject();
        docBuilder.field("doc").startObject(); // This is needed to designate
                                               // the document
        docBuilder.field("content", "This is amazing!");
        docBuilder.endObject(); // End of the doc field
        docBuilder.endObject(); // End of the JSON root object
        // Percolate
        PercolateResponse response = client.preparePercolate("myIndexName", "myDocumentType") //
                .setSource(docBuilder) //
                .execute() //
                .actionGet();
        // Iterate over the results
        for (String result : response) {
            // Handle the result which is the name of
            // the query in the percolator
        }
    }
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:31,代码来源:ElasticSearchTest.java


示例7: ReduceResult

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
ReduceResult(long count, PercolateResponse.Match[] matches, InternalAggregations reducedAggregations) {
    this.count = count;
    this.matches = matches;
    this.reducedAggregations = reducedAggregations;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:6,代码来源:PercolatorService.java


示例8: matches

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
public PercolateResponse.Match[] matches() {
    return matches;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:PercolatorService.java


示例9: executePercolate

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
void executePercolate(final PercolateRequest percolateRequest, final RestChannel restChannel, final Client client) {
    client.percolate(percolateRequest, new RestToXContentListener<PercolateResponse>(restChannel));
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:4,代码来源:RestPercolateAction.java


示例10: checkPercolateResponse

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
/**
 *
 */
private void checkPercolateResponse()
{
  ElasticSearchPercolatorOperator oper = new ElasticSearchPercolatorOperator();
  oper.hostName = HOST_NAME;
  oper.port = PORT;
  oper.indexName = INDEX_NAME;
  oper.documentType = DOCUMENT_TYPE;
  oper.setup(null);

  String[] messages = {"{content:'This will match only with malhar'}",

    "{content:'This will match only with github'}",

    "{content:'This will match with both github and malhar'}",

    "{content:'This will not match with any of them'}"

  };

  String[][] matches = {

    {MALHAR_TOPIC},

    {GITHUB_TOPIC},

    {GITHUB_TOPIC, MALHAR_TOPIC},

    {}

  };

  CollectorTestSink<PercolateResponse> sink = new CollectorTestSink<PercolateResponse>();
  oper.outputPort.setSink((CollectorTestSink)sink);

  for (String message : messages) {
    oper.inputPort.process(message);
  }

  int i = 0;
  for (PercolateResponse response : sink.collectedTuples) {
    List<String> matchIds = new ArrayList<String>();
    for (Match match : response.getMatches()) {
      matchIds.add(match.getId().toString());
    }
    Collections.sort(matchIds);

    Assert.assertArrayEquals(matchIds.toArray(), matches[i]);
    i++;
  }
}
 
开发者ID:apache,项目名称:apex-malhar,代码行数:54,代码来源:ElasticSearchPercolateTest.java


示例11: doExecute

import org.elasticsearch.action.percolate.PercolateResponse; //导入依赖的package包/类
@Override
protected ActionFuture<PercolateResponse> doExecute(PercolateRequest request) {
    return client.percolate(request);
}
 
开发者ID:javanna,项目名称:elasticshell,代码行数:5,代码来源:PercolateRequestBuilder.java



注:本文中的org.elasticsearch.action.percolate.PercolateResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DaoGenerator类代码示例发布时间:2022-05-23
下一篇:
Java JarFile类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap