elasticsearch5.5.3:在不知道id的情況下,全文過濾出來某字段爲xxx後,取出此條數據

es的需求:在不知道id的情況下,全文過濾出來某字段爲xxx後,取出此條數據,使用spark-es非常好做(即https://segmentfault.com/a/1190000015710349?utm_source=tag-newest)

我的spark1.6.0,scala2.10,阿里es5.5.3,下文記錄一下pom文件中使用不同的版本報錯的解決歷程。搗鼓半天
1.使用
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch-spark-20 -->
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch-spark-20_2.10</artifactId>
    <version>5.3.3</version>
</dependency>
報錯:
Exception in thread "main" org.elasticsearch.hadoop.rest.EsHadoopInvalidRequest: [HEAD] on [store] failed; server[x.x.x.x:9200] returned [401|Unauthorized:]
2.使用:            
<!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch-spark -->
<dependency>
    <groupId>org.elasticsearch</groupId>
    <artifactId>elasticsearch-spark_2.10</artifactId>
    <version>2.3.3</version>
</dependency>
報錯:
Exception in thread "main" org.elasticsearch.hadoop.EsHadoopIllegalArgumentException: Cannot detect ES version - typically this happens if the network/Elasticsearch cluster is not accessible or when targeting a WAN/Cloud instance without the proper setting 'es.nodes.wan.only'
首先把sc.set("es.nodes.wan.only", "true")後,報錯同。
對比此文發現spark1.6不支持es5.0,https://blog.csdn.net/u012940753/article/details/52982235
再查https://blog.csdn.net/liulu930507/article/details/78557859,此文提供的pom依賴的網址發現,果然spark2.x才支持es5.0.x

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章