【问题标题】:Eager loading in elastic search弹性搜索中的急切加载
【发布时间】:2016-06-21 06:59:52
【问题描述】:

我正在尝试在弹性搜索中进行 Eagerloading。 我的索引如下-

{"index":{"_index":"appname-ticketing","_type":"BLR"}}

我的映射如下-

    {
  "appname-ticketing" : {
    "mappings" : {
    "BLR" : {
       "AppName" : {
            "type" : "string",
            "index" : "not_analyzed"
          }
        },
    "ABC" : {
       "AppName" : {
            "type" : "string",
            "index" : "not_analyzed"
          }
        }
    }
}

所以 index 是 appname-ticketing 并且 type 是 BLR。 对于字段AppName,我想启用急切加载。 这就是我正在做的-

curl -XPUT localhost:9200/appname-ticketing/BLR/_mapping/AppName -d"
{
  \"tags\": {
    \"type\": \"string\", \"index\" : \"not_analyzed\",
    \"fielddata\": {
      \"loading\" : \"eager\" 
    }
  }
}"

但我收到以下错误-

No handler found for uri [/appname-ticketing/BLR/_mapping/AppName] and method [PUT]

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    我认为添加 update_all_types 参数会更新 BLR 和 ABC 以及所有其他类型中的文本字段:

    发生这种情况是因为映射本质上被扁平化为整个索引的单个全局架构。这就是为什么两种类型不能定义冲突字段的原因。see this

    当映射被展平在一起时,Lucene 不知道该怎么做,因此会出现错误。

    所以你需要做这样的事情:

    curl -XPUT localhost:9200/appname-ticketing/_mapping/BLR/?update_all_type -d '{
      "properties": {
        "AppName": {
          "type": "string", 
          "index" : "not_analyzed",
          "fielddata": {
            "loading" : "eager" 
          }
        }
      }
    }'
    

    如需进一步参考,您可以查看 this link

    【讨论】:

    • 感谢提及update_all_type 参数,好电话! +1
    【解决方案2】:

    你应该这样做:

    curl -XPUT localhost:9200/appname-ticketing/BLR/_mapping -d '{
      "properties": {
        "AppName": {
          "type": "string", 
          "index" : "not_analyzed",
          "fielddata": {
            "loading" : "eager" 
          }
        }
      }
    }'
    

    【讨论】:

    • 对不起,我不是很清楚。请查看我在问题中的更新,了解我使用过的映射。尝试修复后,我收到以下错误-Mapper for [AppName] conflicts with existing mapping in other types:\n[mapper [AppName] is used by multiple types.
    • 是的,您不能在一个索引中的两个不同映射类型中拥有两个名称相同但设置不同的字段。见this
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-27
    • 1970-01-01
    • 2017-04-02
    • 1970-01-01
    • 2017-10-19
    相关资源
    最近更新 更多