悟空,拿我的打狗棒来

6.1.2如何用java创建下图Mapping映射(重点是board_train_code字段)

Elasticsearch | 作者 lzc | 发布于2018年04月18日 | 阅读数:2126

PUT /abc
{
  "settings": {
    "number_of_shards": "10",
    "number_of_replicas": "1"
  },
    "mappings": {
      "doc": {
        "dynamic": "strict",
        "properties": {
          "address": {
            "type": "text",
            "analyzer": "ik_max_word"
          },
          "board_train_code": {
            "type": "text",
            "fields": {
              "keyword": {
                "type": "keyword",
                "ignore_above": 256
              }
            }
          },
          "borad_train_code": {
            "type": "text",
            "analyzer": "ik_max_word"
          }
        }
      }
    }
}

 
已邀请:

medcl - 今晚打老虎。

赞同来自:

borad_train_code
board_train_code
这样的两个字段名,我也是醉了,稍不留神,就选错了。
Java 创建 mapping 官网不是有文档么:
https://www.elastic.co/guide/e ... .html

lzc

赞同来自:

不好意思,我搞错了....
我的意思是:比如字段为name,那么如何创建name和name.keyword两个字段
我按下面这样做不行啊
elasticsearch版本6.1.2

PUT /abc
{
  "settings": {
    "number_of_shards": "10",
    "number_of_replicas": "1"
  },
  "mappings": {
    "doc": {
      "dynamic": "true",
      "properties": {
        "action": {
          "type": "text",
          "fields": {
            "keyword": {
              "type": "keyword",
              "ignore_above": 256
            }
          }
        }
      }
    }
  }
}
 

es_zoom

赞同来自:

正常吧

要回复问题请先登录注册