首页 > 解决方案 > elasticsearch删除映射并了解字段值如何存储

问题描述

我只是在此处浏览弹性搜索映射的文档,并遇到以下解释:-

最初,我们谈到“索引”类似于 SQL 数据库中的“数据库”,“类型”相当于“表”。

然后是这样的例子: -

在 Elasticsearch 索引中,不同映射类型中具有相同名称的字段在内部由相同的 Lucene 字段支持。换句话说,使用上面的示例,用户类型中的 user_name 字段与 tweet 类型中的 user_name 字段存储在完全相同的字段中,并且两个 user_name 字段在两种类型中必须具有相同的映射(定义)。

例如,当您希望 delete 成为同一索引中一种类型的日期字段和另一种类型的布尔字段时,这可能会导致挫败感。

这到底是什么意思?让我们看下面的例子。

PUT myApplesEcommerceSite
{
  "mappings": {
    "properties": {
      "user": {
        "type": "text",
        "fields": {
          "username": {
            "type": "keyword",
          }
        }
      }
    }
  }
}

// so is the fields --> username stored in the same place and both have to be the same type for 2 different indexes ?

PUT myCarShowRoomUser
{
  "mappings": {
    "properties": {
      "user": {
        "type": "text",
        "fields": {
          "username": {
            "type": "integer",
          }
        }
      }
    }
  }
}

那么fields --> username存储在同一个地方并且对于2个不同的索引都必须是相同的类型吗?

标签: elasticsearchelasticsearch-6elasticsearch-7

解决方案


推荐阅读