我正在使用elasticsearch 文档中的这段代码来创建索引。我应该能够将 Postman 的索引配置对象粘贴到我的 Java 代码中。
request.source("{\n" +
" \"settings\" : {\n" +
" \"number_of_shards\" : 1,\n" +
" \"number_of_replicas\" : 0\n" +
" },\n" +
" \"mappings\" : {\n" +
" \"properties\" : {\n" +
" \"message\" : { \"type\" : \"text\" }\n" +
" }\n" +
" },\n" +
" \"aliases\" : {\n" +
" \"twitter_alias\" : {}\n" +
" }\n" +
"}", XContentType.JSON);
当我执行 GET /index_name 时,我看到一个包含两个映射部分的奇怪结构的索引。为什么是这样?我希望有一个映射和一个设置部分。
{
"contacts_4_3t88f9nabk": {
"aliases": {},
"mappings": {
"properties": {
"aliases": {
"properties": {
"twitter_alias": {
"type": "object"
}
}
},
"mappings": {
"properties": {
"properties": {
"properties": {
"message": {
"properties": {
"type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}
},
"settings": {
"properties": {
"number_of_replicas": {
"type": "long"
},
"number_of_shards": {
"type": "long"
}
}
}
}
},
"settings": {
"index": {
"creation_date": "1589442095340",
"number_of_shards": "1",
"number_of_replicas": "1",
"uuid": "othIq5Q2Sgy4eZ3xkxkneg",
"version": {
"created": "7060199"
},
"provided_name": "contacts_4_3t88f9nabk"
}
}
}
}