// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
= image:kamelets/elasticsearch-index-sink.svg[] ElasticSearch Index Sink

*Provided by: "Apache Software Foundation"*

*Support Level for this Kamelet is: "Preview"*

This sink stores documents into ElasticSearch.

Input data must have JSON format according to the index used.

- `indexId` / `ce-indexId`: as the index ID for Elasticsearch

If the header won't be set the exchange ID will be used as index.

- `indexName` / `ce-indexName`: as the index Name for Elasticsearch

If the header won't be set the exchange ID will be used as index name.

== Configuration Options

The following table summarizes the configuration options available for the `elasticsearch-index-sink` Kamelet:
[width="100%",cols="2,^2,3,^2,^2,^3",options="header"]
|===
| Property| Name| Description| Type| Default| Example
| *clusterName {empty}* *| ElasticSearch Cluster Name| Name of the cluster.| string| | `"quickstart"`
| *hostAddresses {empty}* *| Host Addresses| Comma separated list with ip:port formatted remote transport addresses to use.| string| | `"quickstart-es-http:9200"`
| enableSSL| Enable SSL| Do we want to connect using SSL?| boolean| `true`| 
| indexName| Index in ElasticSearch| The name of the index to act against.| string| | `"data"`
| password| Password| Password to connect to ElasticSearch.| string| | 
| user| Username| Username to connect to ElasticSearch.| string| | 
|===

NOTE: Fields marked with ({empty}*) are mandatory.

== Usage

This section summarizes how the `elasticsearch-index-sink` can be used in various contexts.

=== Knative Sink

The `elasticsearch-index-sink` Kamelet can be used as Knative sink by binding it to a Knative object.

.elasticsearch-index-sink-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: elasticsearch-index-sink-binding
spec:
  source:
    ref:
      kind: InMemoryChannel
      apiVersion: messaging.knative.dev/v1
      name: mychannel
  sink:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: elasticsearch-index-sink
    properties:
      clusterName: "quickstart"
      hostAddresses: "quickstart-es-http:9200"
  
----
Make sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.

Save the `elasticsearch-index-sink-binding.yaml` file into your hard drive, then configure it according to your needs.

You can run the sink using the following command:

[source,shell]
----
kubectl apply -f elasticsearch-index-sink-binding.yaml
----

==== *Binding to Knative using the Kamel CLI:*

The procedure described above can be simplified into a single execution of the `kamel bind` command:

[source,shell]
----
kamel bind channel/mychannel elasticsearch-index-sink -p "sink.clusterName=quickstart" -p "sink.hostAddresses=quickstart-es-http:9200"
----

This will create the KameletBinding under the hood and apply it to the current namespace in the cluster.

=== Kafka Sink

The `elasticsearch-index-sink` Kamelet can be used as Kafka sink by binding it to a Kafka topic.

.elasticsearch-index-sink-binding.yaml
[source,yaml]
----
apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
metadata:
  name: elasticsearch-index-sink-binding
spec:
  source:
    ref:
      kind: KafkaTopic
      apiVersion: kafka.strimzi.io/v1beta1
      name: my-topic
  sink:
    ref:
      kind: Kamelet
      apiVersion: camel.apache.org/v1alpha1
      name: elasticsearch-index-sink
    properties:
      clusterName: "quickstart"
      hostAddresses: "quickstart-es-http:9200"
  
----

Ensure that you've installed https://strimzi.io/[Strimzi] and created a topic named `my-topic` in the current namespace.
Make also sure you have xref:latest@camel-k::installation/installation.adoc[Camel K installed] into the Kubernetes cluster you're connected to.

Save the `elasticsearch-index-sink-binding.yaml` file into your hard drive, then configure it according to your needs.

You can run the sink using the following command:

[source,shell]
----
kubectl apply -f elasticsearch-index-sink-binding.yaml
----

==== *Binding to Kafka using the Kamel CLI:*

The procedure described above can be simplified into a single execution of the `kamel bind` command:

[source,shell]
----
kamel bind kafka.strimzi.io/v1beta1:KafkaTopic:my-topic elasticsearch-index-sink -p "sink.clusterName=quickstart" -p "sink.hostAddresses=quickstart-es-http:9200"
----

This will create the KameletBinding under the hood and apply it to the current namespace in the cluster.

// THIS FILE IS AUTOMATICALLY GENERATED: DO NOT EDIT
