doutou7549 2015-02-26 14:47
浏览 83
已采纳

不确定我的映射是否在Elasticsearch中有效

Im using ES with my Laravel app using this Elasticquent package.

My mapping looks like this before I index my DB:

'ad_title' => [
            'type' => 'string',
            'analyzer' => 'standard'
        ],
        'ad_type' => [
            'type' => 'integer',
            'index' => 'not_analyzed'
        ],
        'ad_type' => [
            'type' => 'integer',
            'index' => 'not_analyzed'
        ],
        'ad_state' => [
            'type' => 'integer',
            'index' => 'not_analyzed'
        ],

But when I do the API call _mapping?pretty afterwards

My mapping looks like this:

"testindex": {
        "mappings": {
            "ad_ad": {
                "properties": {
                    "ad_city": {
                        "type": "integer"
                    },
                    "ad_id": {
                        "type": "long"
                    },
                    "ad_state": {
                        "type": "integer"
                    },
                    "ad_title": {
                        "type": "string",
                        "analyzer": "standard"
                    },
                    "ad_type": {
                        "type": "integer"
                    },

Shouldnt I be able to see 'index' => 'not_analyzed' in my mapping afterwards? Or does 'index' => 'not_analyzed' not show in the map structure afterwards?

  • 写回答

1条回答 默认 最新

  • doutangxi2144 2015-02-26 17:27
    关注

    You are correct, the mapping did not get applied. You would see the not_analyzed in the mapping API if it was applied correctly.

    Make sure that you apply the mapping BEFORE you write any data. We apply the mapping on application startup to verify the mapping is always correct and to apply any mapping updates.

    Here is a sample of how to apply a mapping:

    PUT hilden1
    
    PUT hilden1/type1/_mapping
    {
      "properties": {
        "regular": {
          "type": "string"
        },
        "indexSpecified": {
          "type": "string",
          "index": "not_analyzed"
        }
      }
    }
    

    To verify that mapping use the GET api

    GET hilden1/type1/_mapping
    

    You should see that the field "regular" only specifies it's type, where as "indexSpecified" is listed as not_analyzed. Here is the output from my machine running ES 1.4.4

    {
       "hilden1": {
          "mappings": {
             "type1": {
                "properties": {
                   "indexSpecified": {
                      "type": "string",
                      "index": "not_analyzed"
                   },
                   "regular": {
                      "type": "string"
                   }
                }
             }
          }
       }
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集