elasticsearch

how to create a mapping for CSV file manually [Elasticsearch]


I've created a mapping named movie1 in Elasticsearch with specific properties for a movie dataset. However, when I attempted to upload a CSV file into Kibana specifying the index name as movie1, it indicated that the index already existed.

put movie1
{
  "mappings":
  {
    "properties":
    {
      "Actor Name":
      {
        "type":"text"
      },
      "Category":
      {
        "type":"text"
      },
      "Cinema Involved":
      {
        "type":"text"
      },
      "Expense of Operation":
      {
        "type":"text"
      },
      "Movie Description":
      {
        "type":"text"
      },
      "Movie ID":
      {
        "type":"text"
      },
      "Movie Length":
      {
        "type":"text"
      },
      "Movie Name":
      {
        "type":"text"
      },
      "Movie Origin":
      {
        "type":"text"
      },
      "Movie Release Date":
      {
        "type":"text"
      },
      "Movie Type":
      {
        "type":"text"
      }
    }
  }
} 

I want to know if it's possible to create a custom mapping for my CSV file without relying on the file-data-visualizer in Kibana. Usually, when directly uploading a CSV file in Kibana, the file-data-visualizer generates a mapping based on the CSV data. I've researched and found suggestions about using an index template, but I'm unsure of the process. Could you provide guidance on how to create a mapping template for my CSV data?


Solution

  • You don't need to create an index template to achieve what you want, although that would work as well.

    You also don't need to create your index beforehand (so delete the one you have first) and you can simply let the File Data Visualizer do it for you. When importing your CSV file, name your index movie1, go to the advanced section and add your mapping in the Mappings section.

    Then click import and you're all set.

    enter image description here