"mappings" 在 Elasticsearch 中做什么?

What does "mappings" do in Elasticsearch?

我刚开始学习 Elasticsearch。我正在尝试创建索引、添加数据、删除数据和搜索数据。 Elasticsearch的设置我也能看懂

使用时"PUT"使用设置

{
"settings": {
"index.number_of_shards" : 1,
"index.number_of_replicas" : 0
 }
}

使用"GET"检索设置信息时

{
"dsm" : {
"settings" : {
  "index" : {
    "creation_date" : "1555487684262",
    "number_of_shards" : "1",
    "number_of_replicas" : "0",
    "uuid" : "qsSr69OdTuugP2DUwrMh4g",
    "version" : {
      "created" : "7000099"
    },
    "provided_name" : "dsm"
  }
}
}
}

然而,

What does "mappings" do in Elasticsearch?

{
  "kibana_sample_data_flights" : {
"aliases" : { },
"mappings" : {
  "properties" : {
    "AvgTicketPrice" : {
      "type" : "float"
    },
    "Cancelled" : {
      "type" : "boolean"
    },
    "Carrier" : {
      "type" : "keyword"
    },
    "Dest" : {
      "type" : "keyword"
    },
    "DestAirportID" : {
      "type" : "keyword"
    },
    "DestCityName" : {

    },  // just part of data

是索引的映射。这意味着它描述了存储在该索引中的数据。深入了解 here.

映射文档是一种描述数据结构和定义类型(例如布尔值、文本、关键字)的方式。这些类型很重要,因为它们决定了如何对您的字段进行索引和分析。

Elasticsearch 支持动态映射,因此可以有效地执行对适当类型的自动最佳猜测,但您可能希望覆盖这些。

我发现这是一篇解释映射过程的有用文章: https://www.elastic.co/blog/found-elasticsearch-mapping-introduction

索引由字段类型决定,例如,当类型为 'keyword' 时,搜索引擎将期待完全匹配,当类型为 'text' 时,搜索引擎将尝试确定文档与查询词的匹配程度如何,这样做将执行 'full text search'.

例如: - 搜索 jump 也应该匹配 jumped、jumps、jumping,甚至可能是 leap。

这是一篇描述精确搜索与全文搜索的好文章,也是我使用跳转示例的地方:https://www.elastic.co/guide/en/elasticsearch/guide/current/_exact_values_versus_full_text.html

elasticsearch 的大部分功能都体现在映射和分析中。