Create index questions

PUT test
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "_doc" : {
            "properties" : {
                "field1" : { "type" : "text" }
            }
        }
    }
}

what does _doc means when creating a index?
Can I specific a typename instead of _doc, as student replacing _doc

PUT test
{
    "settings" : {
        "number_of_shards" : 1
    },
    "mappings" : {
        "students" : {
            "properties" : {
                "field1" : { "type" : "text" }
            }
        }
    }
}

That is the _type. This is deprecated and will be removed in 7.0, so we would suggest not using anything but that default value.

You should add this as a new field instead.

/index/${typename}/

I wanna create a mapping for this type
/test/students as for students
how does it become a field name other than a typename

Don't do that.

Put "typename": "student" in your document.

Sorry, I am quite new to elastic.
the purpose is to create a index name test and initialize the mapping of a typename = "students"

PUT test
{
  "settings": {
        "number_of_replicas": 1,
        "number_of_shards": 1
  },
  "mappings" : {
    "_doc" : {
        "properties" : {
            "field1" : { "type" : "text" }
        }
    }
 }
}

above that's referring to the docs,
I am quite confusing here(what is _doc means here)
So I am intent to replace _doc to students, because students is my table name(in elastic world typename)

probably I misused the word typename
below is what I want as a result for each document
_index: "test", _type: "students"

As your said:

Put "typename": "student" in your document.

I don't really know

  1. where should I put my "typename": "student" to.
  2. And how to achieve my purpose initialize a index with a typename(table name) as well as set the mapping of the typename's fields

Many thanks.

Do this;

PUT test
{
  "settings": {
        "number_of_replicas": 1,
        "number_of_shards": 1
  },
  "mappings" : {
    "_doc" : {
        "properties" : {
            "field1" : { "type" : "text" },
            "typename" : { "type" : "text" }
        }
    }
 }
}

Ignore _doc, ignore _type, they are deprecated features and using them will only cause more problems.

Sorry, I thought you still misunderstand.
I wanna the type be the table name . like this test/students/1

And, specify the filed such as name, gender, id, age of students not on index,
_index: "test", _type: "students"

So, I am intent to do

PUT test
 "mappings" : {
    "students" : {
        "properties" : {
            "field1" : { "type" : "text" }
        }
    }
 }

in your last reply

PUT test
{
  "settings": {
        "number_of_replicas": 1,
        "number_of_shards": 1
  },
  "mappings" : {
    "_doc" : {
        "properties" : {
            "field1" : { "type" : "text" },
            "typename" : { "type" : "text" }
        }
    }
 }
}

I thought you still used the _doc.
Is there something I misunderstand about mappings?

Please read https://www.elastic.co/blog/removal-of-mapping-types-elasticsearch.

As I have been saying - Do Not Use Types. They will be removed very soon.
If you use this type then you will need to make more changes in the very near future.

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