【发布时间】:2014-03-27 10:22:05
【问题描述】:
你好 stackoverflowers!
我正在尝试将库 elastic4s 与 scala 一起使用,但是当我运行以下代码时(为了获取索引广告中的广告列表):
trait elastic4s {
def get: Future[SearchResponse] = {
val client = ElasticClient.local
client execute { search in "ads"->"ad" }
}
}
我遇到了这个异常:
An error has occured: org.elasticsearch.indices.IndexMissingException: [ads] missing
使用full output here.粘贴bin
这是我的配置:
-- Java
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
-- ElasticSearch
version 1.0.1
-- Elastic4s
version 2.10-1.0.1
Elastic Search 已在 localhost:9200 上启动并运行,并且存在此索引广告。这个 CURL 请求:
curl -XGET 'http://localhost:9200/ads/ad/_search'
返回
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 1,
"hits": [
{
"_index": "ads",
"_type": "ad",
"_id": "UrKm89AXTzOxB9kFdpue4Q",
"_score": 1,
"_source": {
"json": "json"
}
}
]
}
}
我不明白...如果有人可以给我一个曲目:)
【问题讨论】:
-
您是否编辑了 Elasticsearch 配置?您的客户端可能有不同的集群名称吗?
-
Nope MeiSign,两边开箱即用的配置(Elastic Search 和 Elastic4s):/
-
如果您使用不同的查询会发生什么?也许是一个简单的集群状态查询或类似的东西?或者您可以尝试使用“_all”作为索引来查看您的客户是否可以访问/查看任何内容。
-
我查看了 Elastic4s 库。尝试使用远程客户端。
val client = ElasticClient.remote("localhost", 9300)我怀疑您的本地节点客户端没有加入您的集群,因此没有找到任何数据... -
感谢美信的这些建议。当我使用这个查询代码客户端执行 { search in "_all"->"ad" } code - 我得到这个响应: code { "took" : 0, "timed_out" : false, "_shards" : { "total" : 0,“成功”:0,“失败”:0 },“命中”:{“total”:0,“max_score”:0.0,“命中”:[] } } 代码。使用 CURL 执行的相同请求会返回 5 个成功的分片。奇怪:(
标签: scala elasticsearch elastic4s