【问题标题】:IndexMissingException with scala and elastic4sIndexMissingException 与 scala 和 elastic4s
【发布时间】: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


【解决方案1】:

本地节点不会与在该进程之外运行的其他 Elasticsearch 实例通信。本地节点是 JVM 的本地节点。

代码 cmets 说:

"节点是本地节点吗。本地节点是使用本地节点的节点 (JVM 级别)发现传输。其他(本地)节点在其中启动 将发现相同的 JVM(实际上是类加载器)并且 进行了交流。不会发现 JVM 之外的节点。”

您需要使用远程客户端连接到外部实例,即使它们在本地运行。我想这似乎违反直觉,但远程实际上意味着基于 IPC 或 Socket。

【讨论】:

  • 感谢僧人的解释。而对于你的真棒 es 客户!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-01-08
  • 1970-01-01
  • 2014-04-25
  • 2015-06-25
  • 1970-01-01
相关资源
最近更新 更多