1

在尝试添加术语方面时,我面临术语被标记为单独单词的问题。例如,如果属性(字段)Kind具有值medium kind of shirtlarge kind of shirt,则术语变为 - mediumlargekindofshirt

为了解决这个问题,建议我更改映射以包含"index": "not_analyzed"每个属性字段。问题是映射是动态生成的,例如-:

"attributes": {
   "properties": {
      "kind": {
         "type": "string"
      },
      "color": {
         "type": "string"
      },
      "size": {
         "type": "string"
      }
   }
}

简单地设置"not_analyzed"里面的位是"attributes"行不通的。有没有办法为字段内的每个子字段设置索引属性attributes

4

1 回答 1

1

感谢安德烈的评论,我能够弄清楚如何应用该设置。

我在我的映射中添加了一个dynamic_templates部分,如下所示:

"dynamic_templates": [
    {
        "string_template": {
            "path_match": "attributes.*",
            "match_mapping_type": "string",
            "mapping": {
                "type": "string",
                "index": "not_analyzed"
            }
        }
    }
]

这可以解决问题,现在每个具有"string"type 的子字段的"index"设置为"not_analyzed". 这些条款不再被标记化。

于 2015-01-14T08:04:38.570 回答