当前位置: 首页>>代码示例>>Java>>正文


Java JavaEsSpark.saveToEs方法代码示例

本文整理汇总了Java中org.elasticsearch.spark.rdd.api.java.JavaEsSpark.saveToEs方法的典型用法代码示例。如果您正苦于以下问题:Java JavaEsSpark.saveToEs方法的具体用法?Java JavaEsSpark.saveToEs怎么用?Java JavaEsSpark.saveToEs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.elasticsearch.spark.rdd.api.java.JavaEsSpark的用法示例。


在下文中一共展示了JavaEsSpark.saveToEs方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testEsRDDWrite

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWrite() throws Exception {
    Map<String, ?> doc1 = ImmutableMap.of("one", 1, "two", 2);
    Map<String, ?> doc2 = ImmutableMap.of("OTP", "Otopeni", "SFO", "San Fran");

    String target = "spark-test/java-basic-write";
    JavaRDD<Map<String, ?>> javaRDD = sc.parallelize(ImmutableList.of(doc1, doc2));
    // eliminate with static import
    JavaEsSpark.saveToEs(javaRDD, target);
    JavaEsSpark.saveToEs(javaRDD, ImmutableMap.of(ES_RESOURCE, target + "1"));

    assertEquals(2, JavaEsSpark.esRDD(sc, target).count());
    assertTrue(RestUtils.exists(target));
    String results = RestUtils.get(target + "/_search?");
    assertThat(results, containsString("SFO"));
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:16,代码来源:AbstractJavaEsSparkTest.java

示例2: run

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
void run(String spanResource, String dependencyLinkResource, SpanAcceptor decoder) {
  log.info("Processing spans from {}", spanResource);
  JavaSparkContext sc = new JavaSparkContext(conf);
  try {
    JavaRDD<Map<String, Object>> links = JavaEsSpark.esJsonRDD(sc, spanResource)
        .groupBy(pair -> traceId(pair._2))
        .flatMapValues(new TraceIdAndJsonToDependencyLinks(logInitializer, decoder))
        .values()
        .mapToPair(link -> new Tuple2<>(new Tuple2<>(link.parent, link.child), link))
        .reduceByKey((l, r) -> DependencyLink.builder()
            .parent(l.parent)
            .child(l.child)
            .callCount(l.callCount + r.callCount)
            .errorCount(l.errorCount + r.errorCount).build())
        .values()
        .map(ElasticsearchDependenciesJob::dependencyLinkJson);

    if (links.isEmpty()) {
      log.info("No spans found at {}", spanResource);
    } else {
      log.info("Saving dependency links to {}", dependencyLinkResource);
      JavaEsSpark.saveToEs(links, dependencyLinkResource,
          Collections.singletonMap("es.mapping.id", "id")); // allows overwriting the link
    }
  } finally {
    sc.stop();
  }
}
 
开发者ID:openzipkin,项目名称:zipkin-dependencies,代码行数:29,代码来源:ElasticsearchDependenciesJob.java

示例3: testEsRDDWriteWithMappingId

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWriteWithMappingId() throws Exception {
    Map<String, ?> doc1 = ImmutableMap.of("one", 1, "two", 2, "number", 1);
    Map<String, ?> doc2 = ImmutableMap.of("OTP", "Otopeni", "SFO", "San Fran", "number", 2);

    String target = "spark-test/java-id-write";
    JavaRDD<Map<String, ?>> javaRDD = sc.parallelize(ImmutableList.of(doc1, doc2));
    // eliminate with static import
    JavaEsSpark.saveToEs(javaRDD, target, ImmutableMap.of(ES_MAPPING_ID, "number"));

    assertEquals(2, JavaEsSpark.esRDD(sc, target).count());
    assertTrue(RestUtils.exists(target + "/1"));
    assertTrue(RestUtils.exists(target + "/2"));
    String results = RestUtils.get(target + "/_search?");
    assertThat(results, containsString("SFO"));
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:16,代码来源:AbstractJavaEsSparkTest.java

示例4: testEsRDDWriteWithMappingExclude

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWriteWithMappingExclude() throws Exception {
    Map<String, ?> doc1 = ImmutableMap.of("reason", "business", "airport", "SFO");
    Map<String, ?> doc2 = ImmutableMap.of("participants", 2, "airport", "OTP");

    String target = "spark-test/java-exclude-write";

    JavaRDD<Map<String, ?>> javaRDD = sc.parallelize(ImmutableList.of(doc1, doc2));
    JavaEsSpark.saveToEs(javaRDD, target, ImmutableMap.of(ES_MAPPING_EXCLUDE, "airport"));

    assertEquals(2, JavaEsSpark.esRDD(sc, target).count());
    assertTrue(RestUtils.exists(target));
    assertThat(RestUtils.get(target + "/_search?"), containsString("business"));
    assertThat(RestUtils.get(target + "/_search?"), containsString("participants"));
    assertThat(RestUtils.get(target + "/_search?"), not(containsString("airport")));
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:16,代码来源:AbstractJavaEsSparkTest.java

示例5: testEsMultiIndexRDDWrite

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsMultiIndexRDDWrite() throws Exception {
  Map<String, ?> doc1 = ImmutableMap.of("reason", "business", "airport", "SFO");
  Map<String, ?> doc2 = ImmutableMap.of("participants", 2, "airport", "OTP");

  String target = "spark-test/java-trip-{airport}";

  JavaRDD<Map<String, ?>> javaRDD = sc.parallelize(ImmutableList.of(doc1, doc2));
  JavaEsSpark.saveToEs(javaRDD, target);

  assertTrue(RestUtils.exists("spark-test/java-trip-OTP"));
  assertTrue(RestUtils.exists("spark-test/java-trip-SFO"));

  assertThat(RestUtils.get("spark-test/java-trip-SFO/_search?"), containsString("business"));
  assertThat(RestUtils.get("spark-test/java-trip-OTP/_search?"), containsString("participants"));
}
 
开发者ID:xushjie1987,项目名称:es-hadoop-v2.2.0,代码行数:16,代码来源:AbstractJavaEsSparkTest.java

示例6: testEsRDDWrite

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWrite() throws Exception {
    Map<String, ?> doc1 = ImmutableMap.of("one", 1, "two", 2);
    Map<String, ?> doc2 = ImmutableMap.of("OTP", "Otopeni", "SFO", "San Fran");

    String target = "spark-test-java-basic-write/data";
    JavaRDD<Map<String, ?>> javaRDD = sc.parallelize(ImmutableList.of(doc1, doc2));
    // eliminate with static import
    JavaEsSpark.saveToEs(javaRDD, target);
    JavaEsSpark.saveToEs(javaRDD, ImmutableMap.of(ES_RESOURCE, target + "1"));

    assertEquals(2, JavaEsSpark.esRDD(sc, target).count());
    assertTrue(RestUtils.exists(target));
    String results = RestUtils.get(target + "/_search?");
    assertThat(results, containsString("SFO"));
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:16,代码来源:AbstractJavaEsSparkTest.java

示例7: testEsRDDWriteWithMappingId

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWriteWithMappingId() throws Exception {
    Map<String, ?> doc1 = ImmutableMap.of("one", 1, "two", 2, "number", 1);
    Map<String, ?> doc2 = ImmutableMap.of("OTP", "Otopeni", "SFO", "San Fran", "number", 2);

    String target = "spark-test-java-id-write/data";
    JavaRDD<Map<String, ?>> javaRDD = sc.parallelize(ImmutableList.of(doc1, doc2));
    // eliminate with static import
    JavaEsSpark.saveToEs(javaRDD, target, ImmutableMap.of(ES_MAPPING_ID, "number"));

    assertEquals(2, JavaEsSpark.esRDD(sc, target).count());
    assertTrue(RestUtils.exists(target + "/1"));
    assertTrue(RestUtils.exists(target + "/2"));
    String results = RestUtils.get(target + "/_search?");
    assertThat(results, containsString("SFO"));
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:16,代码来源:AbstractJavaEsSparkTest.java

示例8: testEsRDDWriteWithMappingExclude

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWriteWithMappingExclude() throws Exception {
    Map<String, ?> doc1 = ImmutableMap.of("reason", "business", "airport", "SFO");
    Map<String, ?> doc2 = ImmutableMap.of("participants", 2, "airport", "OTP");

    String target = "spark-test-java-exclude-write/data";

    JavaRDD<Map<String, ?>> javaRDD = sc.parallelize(ImmutableList.of(doc1, doc2));
    JavaEsSpark.saveToEs(javaRDD, target, ImmutableMap.of(ES_MAPPING_EXCLUDE, "airport"));

    assertEquals(2, JavaEsSpark.esRDD(sc, target).count());
    assertTrue(RestUtils.exists(target));
    assertThat(RestUtils.get(target + "/_search?"), containsString("business"));
    assertThat(RestUtils.get(target + "/_search?"), containsString("participants"));
    assertThat(RestUtils.get(target + "/_search?"), not(containsString("airport")));
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:16,代码来源:AbstractJavaEsSparkTest.java

示例9: testEsMultiIndexRDDWrite

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsMultiIndexRDDWrite() throws Exception {
  Map<String, ?> doc1 = ImmutableMap.of("reason", "business", "airport", "SFO");
  Map<String, ?> doc2 = ImmutableMap.of("participants", 2, "airport", "OTP");

  String target = "spark-test-java-trip-{airport}/data";

  JavaRDD<Map<String, ?>> javaRDD = sc.parallelize(ImmutableList.of(doc1, doc2));
  JavaEsSpark.saveToEs(javaRDD, target);

  assertTrue(RestUtils.exists("spark-test-java-trip-OTP/data"));
  assertTrue(RestUtils.exists("spark-test-java-trip-SFO/data"));

  assertThat(RestUtils.get("spark-test-java-trip-SFO/data/_search?"), containsString("business"));
  assertThat(RestUtils.get("spark-test-java-trip-OTP/data/_search?"), containsString("participants"));
}
 
开发者ID:elastic,项目名称:elasticsearch-hadoop,代码行数:16,代码来源:AbstractJavaEsSparkTest.java

示例10: percistToElasticSearch

import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public static void percistToElasticSearch(JavaRDD<Person> personsRdd) {
    JavaEsSpark.saveToEs(personsRdd, ES_INDEX + "/" + ES_DOCTYPE, ImmutableMap.of("es.mapping.id", "userName"));
}
 
开发者ID:echauchot,项目名称:bigDataRocks,代码行数:4,代码来源:ElasticSearchWriteService.java


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