Question

Answers

  • user image
    Anurag Srivastava
    Oct 11, 2020, 8:38:28 AM |

    We can read the CSV file data and can push it to Elasticsearch using Logstash and for that, we need to create a Logstash configuration file. You need to write the following expression in the Logstash configuration file (for example the configuration file name: "crimes.conf"):

    input {
        file {
            path => "/home/user/Downloads/crimes_2001.csv"
            start_position => beginning
        }
    }
    filter {
        csv {
            columns => [
                    "ID",
                    "Case Number",
                    "Date",
                    "Block",
                    "IUCR",
                    "Primary Type",
                    "Description",
                    "Location Description",
                    "Arrest",
                    "Domestic",
                    "Beat",
                    "District",
                    "Ward",
                    "Community Area",
                    "FBI Code",
                    "X Coordinate",
                    "Y Coordinate",
                    "Year",
                    "Updated On",
                    "Latitude",
                    "Longitude",
                    "Location"
            ]
            separator => ","
            }
    }
    output {
        stdout
        {
            codec => rubydebug
        }
         elasticsearch {
            action => "index"
            hosts => ["127.0.0.1:9200"]
            index => "crimes"
        }
    }
    

    After creating the Logstash configuration file execute the configuration using the following command:
    /usr/share/logstash/bin/logstash -f /etc/logstash/conf.d/crimes.conf 
    

    This command will create the pipeline to read the CSV data and to write it into Elasticsearch. You can verify the index "crimes" creation in Elasticsearch by listing indices. 

    For more details, you can refer to my blog: "Loading CSV Data into Elasticsearch"

    In case of any queries please leave your comments.
    0 | 0


Related Blogs

preview thumbnail
Introduction to Kibana

Aug 1, 2020, 6:19:45 PM | Anurag Srivastava

preview thumbnail
Bucket Aggregation in Elasticsearch

Aug 29, 2018, 7:15:06 PM | Anurag Srivastava

preview thumbnail
Metrics Aggregations in Elasticsearch

Aug 18, 2018, 6:02:20 PM | Anurag Srivastava

preview thumbnail
Introduction to Elasticsearch Aggregations

Aug 14, 2018, 4:47:56 PM | Anurag Srivastava

preview thumbnail
Wildcard and Boolean Search in Elasticsearch

Aug 10, 2018, 7:14:40 PM | Anurag Srivastava

preview thumbnail
Basics of Data Search in Elasticsearch

Aug 4, 2018, 7:02:21 AM | Anurag Srivastava

Top Blogs

preview thumbnail
Wildcard and Boolean Search in Elasticsearch

Aug 10, 2018, 7:14:40 PM | Anurag Srivastava

preview thumbnail
Elasticsearch REST APIs

Jul 31, 2018, 6:16:42 PM | Anurag Srivastava

preview thumbnail
preview thumbnail
Create a Chess board in PHP

Mar 9, 2020, 8:45:41 AM | Rocky Paul

preview thumbnail
Bucket Aggregation in Elasticsearch

Aug 29, 2018, 7:15:06 PM | Anurag Srivastava

preview thumbnail
Metrics Aggregations in Elasticsearch

Aug 18, 2018, 6:02:20 PM | Anurag Srivastava