ElasticSearch - murmur3哈希中的doc_value

时间:2015-06-11 12:45:28

标签: elasticsearch

继续previous question.

我想做什么?

感谢@AndreiStefan我尝试使用murmur3doc_values哈希从堆中删除:

"dynamic_templates": [
{
  "murmur3_hashed": {
    "mapping": {
      "index": "not_analyzed",
      "norms": {
        "enabled": false
      },
      "fielddata": {
        "format": "doc_values"
      },
      "doc_values": true,
      "type": "string",
      "fields": {
        "hash": {
          "index": "no",
          "doc_values": true,
          "type": "murmur3"
        }
      }
    },
    "match_mapping_type": "string",
    "match": "my_prop"
  }
}
]

我使用stream2es进行重建索引。

结果是什么?

重建索引后,结果属性为:

  "my_prop": {
    "index": "not_analyzed",
    "fielddata": {
      "format": "doc_values"
    },
    "doc_values": true,
    "type": "string",
    "fields": {
      "hash": {
        "null_value": -1,
        "precision_step": 2147483647,
        "type": "murmur3"
      }
    }
  },

有什么问题?

为什么结果属性中缺少"index": "no", "doc_values": true

1 个答案:

答案 0 :(得分:0)

这是我在ES 1.6.0中测试的命令列表:

PUT /test
{
  "mappings": {
    "_default_": {
      "dynamic_templates": [
        {
          "murmur3_hashed": {
            "mapping": {
              "index": "not_analyzed",
              "norms": {
                "enabled": false
              },
              "fielddata": {
                "format": "doc_values"
              },
              "doc_values": true,
              "type": "string",
              "fields": {
                "hash": {
                  "index": "no",
                  "doc_values": true,
                  "type": "murmur3"
                }
              }
            },
            "match_mapping_type": "string",
            "match": "my_prop"
          }
        }
      ]
    }
  }
}

POST /test/test_type/1
{
  "my_prop": "xxx"
}

GET /test/test_type/_mapping

我得到了这个输出:

{
   "test": {
      "mappings": {
         "test_type": {
            "dynamic_templates": [
               {
                  "murmur3_hashed": {
                     "mapping": {
                        "fielddata": {
                           "format": "doc_values"
                        },
                        "norms": {
                           "enabled": false
                        },
                        "index": "not_analyzed",
                        "type": "string",
                        "fields": {
                           "hash": {
                              "index": "no",
                              "type": "murmur3",
                              "doc_values": true
                           }
                        },
                        "doc_values": true
                     },
                     "match": "my_prop",
                     "match_mapping_type": "string"
                  }
               }
            ],
            "properties": {
               "my_prop": {
                  "type": "string",
                  "index": "not_analyzed",
                  "doc_values": true,
                  "fielddata": {
                     "format": "doc_values"
                  },
                  "fields": {
                     "hash": {
                        "type": "murmur3",
                        "index": "no",
                        "doc_values": true,
                        "precision_step": 2147483647,
                        "null_value": -1
                     }
                  }
               }
            }
         }
      }
   }
}