数据使用骆驼索引到弹性搜索中,但在 Kibana 或 localhost:9200 中看不到

Data getting indexed into elastic search using camel but can't be seen in Kibana or localhost:9200

我正在尝试使用 Apache camel 将一些针对某个 ID 的数据插入到弹性搜索中。我已经插入依赖项:

<dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-elasticsearch</artifactId>
</dependency>

我正在使用 JSONObject,如下所示:

{
"indexId" : "someId",
"messages" : {"message1" : "data1", "message2":"data2"}

}

并且正在使用以下方式插入数据:

<to id="elastic_search_camel"
                uri="elasticsearch://local?operation=INDEX&amp;indexName=messages&amp;indexType=message" />

我还可以使用 operation=GET_BY_ID 将数据打印回控制台。但是我无法在 Kibana 或 localhost:9200 中看到 index/data。

有人可以帮我解决这个问题吗? 提前致谢。

您需要检查索引是否存在 - 您可以 运行

GET es-url:9200/_cat/indices/messages*

并确保索引存在。如果索引不存在,则索引存在问题 - 您需要提前创建索引,或者在 elasticsearch 和 camel 生产者中查找失败原因的异常。

确保数据按预期在 ES 中建立索引后,您可以进入 kibana-> settings -> index-patterns 并为这些新索引模式添加索引模式。之后您将能够在 kibana

中看到数据

我正在使用 apache Camel 连接到 ElasticSearch 服务器。 Camel 创建了自己的 elasticsearch 集群,因此它没有连接到我的 运行 服务器。要停止此特定行为,您需要在创建 uri 时明确指定 IP 和端口:

<to id="elastic_search_camel"
                uri="elasticsearch://<clusterName>?operation=INDEX&amp;indexName=messages&amp;indexType=doc&amp;ip=x.x.x.x&amp;port=9300" />

注意:参数 transportAddresses 也可用于指定 ip:port 格式的列表。查看 http://camel.apache.org/elasticsearch.html 以了解详细信息。

在 config/elasticsearch.yml 文件中指定相同的内容:

http.port: 9200
network.host: x.x.x.x
cluster.name: <clusterName>
network.bind_host: 0

maven 中的依赖关系:

<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-elasticsearch</artifactId>
</dependency>
<dependency>
    <groupId>net.java.dev.jna</groupId>
    <artifactId>jna</artifactId>
    <version>4.1.0</version>
</dependency>

在弹性搜索的选项中,也可以使用elasticsearch-rest。 其中路由可以指定为:

<to id="elastic_search_camel"
            uri="elasticsearch-rest://<clusterName>?operation=INDEX&amp;indexName=messages&amp;indexType=doc&amp;hostAddresses=x.x.x.x:9200" />

文档可用:Elastic Search Rest

Maven dependencies : 
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-elasticsearch-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.camel</groupId>
            <artifactId>camel-elasticsearch-rest-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>net.java.dev.jna</groupId>
            <artifactId>jna</artifactId>
            <version>4.1.0</version>
        </dependency>