Git Product home page Git Product logo

elasticsearch-river-csv's Introduction

CSV River Plugin for ElasticSearch

The CSV River plugin allows index CSV files in folder.

In order to install the plugin, simply run: bin/plugin -install river-csv -url https://github.com/AgileWorksOrg/elasticsearch-river-csv/releases/download/2.1.0/elasticsearch-river-csv-2.1.0.zip.

If it doesn't work, clone git repository and build plugin manually.

-------------------------------------
| CSV Plugin | ElasticSearch        |
-------------------------------------
| master         | 1.1.2 -> master |
-------------------------------------
| 2.0.2          | 1.0.x -> 1.2.x  |
-------------------------------------
| 2.0.1          | 1.0.x -> 1.2.x  |
-------------------------------------
| 2.0.0          | 1.0.0            |
-------------------------------------
| 1.0.1          | 0.19.x           |
-------------------------------------
| 1.0.0          | 0.19.x           |
-------------------------------------

The CSV river import data from CSV files and index it.

##Changelog

###2.1.1-SNAPSHOT

  • added support for custom charset

###2.1.0

  • Works with ElasticSearch 1.2.x - 1.3.x

###2.0.2

  • Minor enhancements

###2.0.1

  • Replaced custom upload logic with BulkProcessor. Inspired from pullrequest by https://github.com/aritratony . Thanks!
  • Added error handling - if something went wrong during line or file processing it is logged, skipped and import continues
  • Added callback feature - custom shell scripts can be called on events: before import, before file processing start, after file is processed and after all files are processed

###2.0.0

  • Updated to ES 1.0.0
  • Fixed - when input file was smaller than batch it didn't saved to ES
  • Added - id column name, documents with ID column can be updated
  • Added - ability to parse first row as header, must be enabled by property

##Creating the CSV river can be done using:

###Minimal curl

curl -XPUT localhost:9200/_river/my_csv_river/_meta -d '
{
    "type" : "csv",
    "csv_file" : {
        "folder" : "/tmp",
        "first_line_is_header":"true"
    }
}'

###Full request

curl -XPUT localhost:9200/_river/my_csv_river/_meta -d '
{
    "type" : "csv",
    "csv_file" : {
        "folder" : "/tmp",
        "filename_pattern" : ".*\\.csv$",
        "poll":"5m",
        "fields" : [
            "column1",
            "column2",
            "column3",
            "column4"
        ],
        "first_line_is_header" : "false",
        "field_separator" : ",",
        "escape_character" : ";",
        "quote_character" : "'",
        "field_id" : "id",
        "field_parent" : "id_parent",
        "concurrent_requests" : "1",
        "charset" : "UTF-8",
        "script_before_all": "/path/to/before_all.sh",
        "script_after_all": "/path/to/after_all.sh",
        "script_before_file": "/path/to/before_file.sh",
        "script_after_file": "/path/to/after_file.sh"
    },
    "index" : {
        "index" : "my_csv_data",
        "type" : "csv_type",
        "bulk_size" : 100,
        "bulk_threshold" : 10
    }
}'
  • takes no arguments

      "script_before_all": "/path/to/before_all.sh"
      "script_after_all": "/path/to/after_all.sh"
    
  • file path is argument

      "script_before_file": "/path/to/before_file.sh",
      "script_after_file": "/path/to/after_file.sh"
    

####Examples how the files look like

    #!/bin/sh
    echo "greetings from shell before all"


    #!/bin/bash
    echo "greetings from shell before file $1"


    #!/bin/bash
    echo "greetings from shell after file $1"


    #!/bin/bash
    echo "greetings from shell after all"

###Optional parameters:

fields = empty - MUST BE SET or first_line_is_header must be set to true

----------------------------------------
| Name              | Default value    |
----------------------------------------
| first_line_is_header   | false       |
----------------------------------------
| filename_pattern   | .*\\.csv$       |
----------------------------------------
| poll              |   60 minutes     |
----------------------------------------
| field_separator   | ,   (for tab separator use ```\t```     |
----------------------------------------
| charset           | UTF-8            |
----------------------------------------
| escape_character  | \                |
----------------------------------------
| quote_character   | "                |
----------------------------------------
| bulk_size         | 100              |
----------------------------------------
| bulk_threshold    | 10               |
----------------------------------------
| concurrent_requests | 1              |
----------------------------------------

####Charset

Default charset is "UTF-8". If you need different, consider to use one of:

  • US-ASCII Seven-bit ASCII, a.k.a. ISO646-US, a.k.a. the Basic Latin block of the Unicode character set
  • ISO-8859-1 ISO Latin Alphabet No. 1, a.k.a. ISO-LATIN-1
  • UTF-8 Eight-bit UCS Transformation Format
  • UTF-16BE Sixteen-bit UCS Transformation Format, big-endian byte order
  • UTF-16LE Sixteen-bit UCS Transformation Format, little-endian byte order
  • UTF-16 Sixteen-bit UCS Transformation Format, byte order identified by an optional byte-order mark

More details about charsets are available at http://docs.oracle.com/javase/6/docs/api/java/nio/charset/Charset.html

License

This software is licensed under the Apache 2 license, quoted below.

Copyright 2012-2013 Martin Bednar, Vitek Tajzich

Licensed under the Apache License, Version 2.0 (the "License"); you may not
use this file except in compliance with the License. You may obtain a copy of
the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
License for the specific language governing permissions and limitations under
the License.

elasticsearch-river-csv's People

Contributors

vtajzich avatar xxbedy avatar

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.