How to add custom document type to Elasticsearch indexing?

Any idea how can I add the document_type => "athena" to my index (stage-athena)? I am using Kibana dev-tool UI by the way.

PUT /stage-athena/athena didn't work!

Elasticsearch queries:

PUT /stage-athena/
PUT /stage-athena/_mapping
{
  "properties" : {
    "@timestamp" : {
      "type" : "date"
    },
    "@version" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "customer_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "farm_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "machine_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "op_date" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "phase_id" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    },
    "rows_captured" : {
      "type" : "long"
    },
    "type" : {
      "type" : "text",
      "fields" : {
        "keyword" : {
          "type" : "keyword",
          "ignore_above" : 256
        }
      }
    }
  }
}

I guess you're using 7.x. From this version you should not use any specific type anymore. Behind the scene the type we are using is _doc. It's better to keep this default value.

In 8.x the type will be completely gone.

1 Like

Yes, _doc is the default document type. I am curious to know if it is useful to have different doucment types in an index?

It's not and it's forbidden in 7.x anyway.

Yes I'm using Elasticsearch 7.2, thanks for your feedback.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.