本文整理汇总了Java中org.elasticsearch.spark.rdd.api.java.JavaEsSpark.saveToEsWithMeta方法的典型用法代码示例。如果您正苦于以下问题:Java JavaEsSpark.saveToEsWithMeta方法的具体用法?Java JavaEsSpark.saveToEsWithMeta怎么用?Java JavaEsSpark.saveToEsWithMeta使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.elasticsearch.spark.rdd.api.java.JavaEsSpark
的用法示例。
在下文中一共展示了JavaEsSpark.saveToEsWithMeta方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEsRDDWriteWithDynamicMapping
import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWriteWithDynamicMapping() 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-dyn-id-write";
JavaPairRDD<?, ?> pairRdd = sc.parallelizePairs(ImmutableList.of(new Tuple2<Object,Object>(1, doc1),
new Tuple2<Object, Object>(2, doc2)));
//JavaPairRDD pairRDD = JavaPairRDD.fromJavaRDD(tupleRdd);
// eliminate with static import
JavaEsSpark.saveToEsWithMeta(pairRdd, target);
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"));
}
示例2: testEsRDDWriteWithDynamicMappingBasedOnMaps
import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWriteWithDynamicMappingBasedOnMaps() 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-dyn-map-id-write";
Map<Metadata, Object> header1 = ImmutableMap.<Metadata, Object> of(ID, 1, TTL, "1d");
Map<Metadata, Object> header2 = ImmutableMap.<Metadata, Object> of(ID, "2", TTL, "2d");
JavaRDD<Tuple2<Object, Object>> tupleRdd = sc.parallelize(ImmutableList.<Tuple2<Object, Object>> of(new Tuple2(header1, doc1), new Tuple2(header2, doc2)));
JavaPairRDD pairRDD = JavaPairRDD.fromJavaRDD(tupleRdd);
// eliminate with static import
JavaEsSpark.saveToEsWithMeta(pairRDD, target);
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"));
}
示例3: testEsRDDWriteWithDynamicMapping
import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWriteWithDynamicMapping() 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-dyn-id-write/data";
JavaPairRDD<?, ?> pairRdd = sc.parallelizePairs(ImmutableList.of(new Tuple2<Object,Object>(1, doc1),
new Tuple2<Object, Object>(2, doc2)));
//JavaPairRDD pairRDD = JavaPairRDD.fromJavaRDD(tupleRdd);
// eliminate with static import
JavaEsSpark.saveToEsWithMeta(pairRdd, target);
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: testEsRDDWriteWithDynamicMappingBasedOnMaps
import org.elasticsearch.spark.rdd.api.java.JavaEsSpark; //导入方法依赖的package包/类
public void testEsRDDWriteWithDynamicMappingBasedOnMaps() 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-dyn-map-id-write/data";
Map<Metadata, Object> header1 = ImmutableMap.<Metadata, Object> of(ID, 1, TTL, "1d");
Map<Metadata, Object> header2 = ImmutableMap.<Metadata, Object> of(ID, "2", TTL, "2d");
JavaRDD<Tuple2<Object, Object>> tupleRdd = sc.parallelize(ImmutableList.<Tuple2<Object, Object>> of(new Tuple2(header1, doc1), new Tuple2(header2, doc2)));
JavaPairRDD pairRDD = JavaPairRDD.fromJavaRDD(tupleRdd);
// eliminate with static import
JavaEsSpark.saveToEsWithMeta(pairRDD, target);
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"));
}