GithubHelp home page GithubHelp logo

sarwarbhuiyan / camel-elasticsearch-http Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 3.0 81 KB

Camel Elasticsearch Component Using HTTP rather than TransportClient

License: Apache License 2.0

Java 100.00%

camel-elasticsearch-http's Introduction

Introduction

The camel-elasticsearch component in the Apache Project (http://camel.apache.org/elasticsearch.html) is based on the Elasticsearch Java client which has different APIs and behaviour depending on whether it was for 1.x or 2.x. The Elasticsearch HTTP API is a little less prone to breaking changes at least with regards to things like index or bulk_index. This component can be used in the same way as the camel-elasticsearch component but makes use of the HTTP API with a Jersey Client.

Build

>mvn clean install

Usage

Update your pom or gradle with the following dependency:

<groupId>com.sarwarbhuiyan</groupId>
<artifactId>camel-elasticsearch-http</artifactId>
<version>0.1.0</version>

In your route, you can use the following URI format:

eshttp://clusterName&ip=<ip address>&port=9200&indexName=<index name>&indexType=<type name>&operation=<operation name>

Where operation name can take the values:

  • INDEX
  • GET_BY_ID
  • DELETE
  • BULK_INDEX
  • SEARCH
  • MULTIGET
  • MULTISEARCH
  • EXISTS
  • UPDATE
  • SCAN_SCROLL (as a consumer endpoint. If this is used as a consumer endpoint and then used to reindex/bulk reindex using an output/producer endpoint, one can use the preserveIds=true parameter to preserve IDs from the source index)

Other parameters supported are:

  • consistencyLevel (can take values ONE, QUORUM, or DEFAULT)

The objects passed to the endpoint can either be JSON strings or Map of Maps representing the JSON to be passed in.

For the most part, this is in keeping with the operations on camel-elasticsearch but not supporting the classes/objects in the Java Elasticsearch Client API.

Connection Pooling and Long-lived HTTP connections are used under the hood by virtue of using Apache HttpClient

Examples:

The following show pipeline builders that can be included in a Camel application:

  1. Reindex from existing Elasticseach to new Elasticsearch index/cluster
from("eshttp://elasticsearch?ip=localhost&port=3000&operation=SCAN_SCROLL&indexName=my-index&scrollSize=10")
    		.aggregate(constant(true), new BulkReindexStrategy())
    		.completionSize(1000)     // set bulk size here
    		.forceCompletionOnStop()
    		.completionTimeout(1000)  // set completion timeout here
    		.to("eshttp://elasticsearch?ip=localhost&port=3000&operation=BULK_INDEX&indexName=my-index2&preserveIds=true");
  1. Read from twitter and index into Elasticsearch
        from("twitter://streaming/sample?type=EVENT&consumerKey=<consumer-key>&consumerSecret=<consumer-secret>&accessToken=<access-token>&accessTokenSecret=<access-token-secret>&delay=1")
        .to("jms:test.TwitterQueue");
        
        from("jms:test.TwitterQueue")
        .marshal().json(JsonLibrary.Jackson)
        .aggregate(constant(true), new BulkIndexStrategy())
		.completionSize(1000)
		.forceCompletionOnStop()
        .to("eshttp://elasticsearch?ip=localhost&port=9300&operation=BULK_INDEX&indexName=twitter&indexType=tweet");

Future Work

  • Load balancing across multiple data nodes
  • Sniffing of all data nodes from network via calls to the cluster

camel-elasticsearch-http's People

Contributors

sarwarbhuiyan avatar

Watchers

 avatar  avatar

camel-elasticsearch-http's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.