本文整理汇总了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"));
}
示例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();
}
}
示例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"));
}
示例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")));
}
示例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"));
}
示例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"));
}
示例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"));
}
示例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")));
}
示例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"));
}
示例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"));
}