【问题标题】:How exactly do mapped fields in elastic search work?弹性搜索中的映射字段究竟是如何工作的?
【发布时间】:2015-09-15 22:08:11
【问题描述】:

The documentation 是稀疏的,并不完全有用。所以说我的属性有以下字段:

{
  "my_index": {
    "mappings": {
      "my_type": {
        "my_attribute": {
          "mapping": {
            "my_attribute": {
              "type": "string",
              "analyzer": "my_analyzer",
              "fields": {
                "lowercased": {
                  "type": "string"
                },
                "raw": {
                  "type": "string",
                  "index": "not_analyzed"
                }
              }
            }
          }
        }
      }
    }
  }
}

my_analyzer 小写标记(除了其他东西)。

所以现在我想知道以下陈述是否属实:

  1. my_analyzer 不会应用于 raw,因为正如其名称所暗示的那样,not_analyzed 索引没有任何分析器。
  2. my_attributemy_attribute.lowercased 完全相同,因此字段 my_attribute.lowercased 是多余的

【问题讨论】:

  • 你的陈述对于 1 和 2 都是正确的

标签: elasticsearch


【解决方案1】:

您的第一个陈述是正确的,但第二个不是。 my_attributemy_attribute.lowercased 可能不一样,因为前者有你的 custom my_analyzer 搜索和索引分析器,而 my_attribute.lowercasedstandard analyzer(因为没有指定分析器标准一个开始)。

另外,你的映射写的不正确,应该是这样的:

{
  "mappings": {
    "my_type": {
      "properties": {
        "my_attribute": {
          "type": "string",
          "analyzer": "my_analyzer",
          "fields": {
            "lowercased": {
              "type": "string"
            },
            "raw": {
              "type": "string",
              "index": "not_analyzed"
            }
          }
        }
      }
    }
  }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-08
    • 2015-05-06
    • 2016-06-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-05
    相关资源
    最近更新 更多