elasticsearch,mappings,Types,elasticsearch,Mappings" /> elasticsearch,mappings,Types,elasticsearch,Mappings" />

Types Elasticseach,类型属性与类型映射,什么';有什么区别?

Types Elasticseach,类型属性与类型映射,什么';有什么区别?,types,elasticsearch,mappings,Types,elasticsearch,Mappings,如果有人能帮助我理解以以下两种形式创建类型之间的真正区别,我将不胜感激: 使用“映射” PUT/mybestfares\u测试1 不使用“映射” PUT/mybestfares\u test2/ { "bestfares_data": { "dynamic" : false, "properties": { "airline": { "type": "string",

如果有人能帮助我理解以以下两种形式创建类型之间的真正区别,我将不胜感激:

使用“映射” PUT/mybestfares\u测试1

不使用“映射” PUT/mybestfares\u test2/

{
    "bestfares_data": {
        "dynamic" : false,
        "properties": {
            "airline": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "N/A"
            },
            "destinationAirport": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "N/A"
            },
            "originAirport": {
                "type": "string",
                "index": "not_analyzed",
                "null_value": "N/A"
            },
            "sellPrice": {
                "type": "double",
                "null_value": 0
            }
        }
    }
}
如果我得到这两个索引的索引信息,很明显,“mybestfares_test2”没有任何“映射”定义,尽管类型中的每个字段都有特定的设置:

GET/mybestfares\u test2=>

{
   "mybestfares_test2": {
      "mappings": {},
      "settings": {
         "index": {
            "creation_date": "1423741207570",
            "uuid": "ognGDfnTS7i9AVE1L66UgA",
            "number_of_replicas": "1",
            "number_of_shards": "5",
            "version": {
               "created": "1040299"
            },
            "bestfares_data": {
              "dynamic" : false,
               "properties": {
                  "destinationAirport": {
                     "type": "string",
                     "null_value": "N/A",
                     "index": "not_analyzed"
                  },
                  "sellPrice": {
                     "type": "double",
                     "null_value": "0"
                  },
                  "originAirport": {
                     "type": "string",
                     "null_value": "N/A",
                     "index": "not_analyzed"
                  },
                  "airline": {
                     "type": "string",
                     "null_value": "N/A",
                     "index": "not_analyzed"
                  }
               }
            }
         }
      }
   }
}
当然,使用mappings创建的索引在mappings{…}部分中具有相同的字段设置 获取/mybestfares\u测试1


我想了解这两个索引之间的行为有哪些不同(如果有)

如果仔细查看响应,则在没有映射的情况下创建的第二个索引实际上会获得许多附加设置。因此,在这种情况下不提供映射。所以第一个是唯一正确的。

来自:

有两种方法可以提供到Elasticsearch的映射。最常见的方法是在创建索引期间:

$ curl -XPOST ...:9200/my_index -d '{
    "settings" : {
        # .. index settings
    },
    "mappings" : {
        "my_type" : {
            # mapping for my_type
        }
    }
}'
提供映射的另一种方法是使用Put映射API

$ curl -XPUT 'http://localhost:9200/my_index/my_type/_mapping' -d '
{
    "my_type" : {
        # mapping for my_type
    }
}
'
此API使我们能够更新已存在索引的映射,但在潜在冲突方面存在一些限制。可以将新的映射定义添加到现有映射中,并且现有类型可能会更新其配置,但是更改类型会被视为冲突,不被接受。但是,可以将ignore_conflicts=true作为参数传递给映射API,但这样做并不保证产生预期的结果,因为已编制索引的文档不会使用新映射自动重新编制索引


因此,在大多数情况下,建议在创建索引期间指定映射,而不是使用Put映射API。

感谢您花时间来了解这一点,我不确定您所说的“唯一正确的一个”是什么意思。Elasticsearch允许您描述类型中的元素,那么,您为什么这么说“这是不正确的”?我所要问的是,使用这种方法与使用显式“映射”有什么区别?在我看来,使用映射是唯一合适的方法,在不使用“映射”的情况下提供它“将向设置部分添加未使用的内容,映射将使用动态映射规则。您好,感谢您查看此内容。”。我知道有两种方法可以添加映射,一种是在创建索引时,另一种是使用PUT映射API,但我的问题不在于此。我的问题是,在类型中使用映射与在不使用映射的情况下定义元素之间有什么区别,就像我在创建索引mybestfares_test2时所做的那样。如果这篇博文是正确的,我理解这没有区别,除了API还允许您在以后做这件事,尽管不建议这样做。我还将关注该线程以获得更好的解释=]我提供的链接不是来自“博客”,而是来自官方的elasticsearch参考指南:-)
$ curl -XPOST ...:9200/my_index -d '{
    "settings" : {
        # .. index settings
    },
    "mappings" : {
        "my_type" : {
            # mapping for my_type
        }
    }
}'
$ curl -XPUT 'http://localhost:9200/my_index/my_type/_mapping' -d '
{
    "my_type" : {
        # mapping for my_type
    }
}
'