【问题标题】:Elasticsearch array of strings being tokenized even with no_analyzed in mapping即使在映射中使用 no_analyzed,Elasticsearch 字符串数组也会被标记化
【发布时间】:2016-03-15 17:49:03
【问题描述】:

这让我发疯了。我的数据中有一些数组,这是一个精简版:

{
"fullName": "Jane Doe",
"comments": [],
"tags": [
    "blah blah tag 1",
    "blah blah tag 1"
],
"contactInformation": {
    "attachments": [
        "some file 1",
        "some file 2",
        "some file 3"
    ]
}
}

好的,我在 elasticsearch 中的映射如下:

curl -XPOST localhost:9200/myindex -d '{
"settings" : {
    "number_of_shards" : 1
},
"mappings" : {
    "docs" : {
        "properties" : {
            “tags” : { "type" : "string", "index" : "not_analyzed" }
            “attachments” : { "type" : "string", "index" : "not_analyzed" }
        }
    }
}
}'

现在,如果我将这些显示为构面,则标签看起来很好,如下所示:

[ ] - 等等标签 1

[ ] - 等等标签 2

但是附件是标记化的,我得到了每个单词的一个方面,即

[ ] - 一些

[ ] - 文件

[ ] - 1

我在想,由于附件属性位于contactInformation 中,我的映射可能需要如下所示: “contactInformation.attachments”:{“type”:“string”,“index”:“not_analyzed”}

但这引发了错误,没想到会出现这个点。

有什么想法吗?

【问题讨论】:

    标签: elasticsearch lucene elasticui


    【解决方案1】:

    请参阅"Complex Core Field Types" 文档(特别是标题为"Mapping for Inner Objects" 的部分)。

    它应该看起来像这样:

    "mappings" : {
      "docs" : {
        "properties" : {
          “tags” : { "type" : "string", "index" : "not_analyzed" },
          "contactInformation": {
            "type": "object",
            "properties": {
              “attachments” : { "type" : "string", "index" : "not_analyzed" }
            }
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-17
      • 1970-01-01
      • 1970-01-01
      • 2017-06-07
      • 1970-01-01
      • 1970-01-01
      • 2010-12-30
      • 2021-11-15
      相关资源
      最近更新 更多