markdown [Mapping] #elasticsearch #snippets

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了markdown [Mapping] #elasticsearch #snippets相关的知识,希望对你有一定的参考价值。


**Get Mapping for an `index`**

``` json
GET /[index]/_mapping
```

**Add Mapping for a 'field'**

``` json
PUT /[index]/_mapping
{
  "properties": {
    "[field]": {
      "type": "double"
    }
  }
}

```

**(OR)**

``` json 
PUT /[index]
{
  "mappings": {
    "default": {
      "dynamic": false,
      "properties": {
        "[field]": {
          "type": "integer"
        },
        "[field]": {
          "type": "boolean"
        },
        "[field]": {
          "type": "integer"
        },
        "[field]": {
          "type": "long"
        }
      }
    }
  }
}

```



**Add Mapping for multiple fields in an 'index'**
(a string field could be mapped as a `text` field for full-text search, and as a `keyword` field for sorting or aggregations)

``` json
PUT /[index]/_mapping
{
  "properties": {
    "[field]": {
      "type": "text"
    },
    
    "[field]": {
      "type": "text",
      "fields": {
        "[field]": {
          "type": "keyword"
        }
      }
    },
    
    "[field]": {
      "type": "text",
      "fields": {
        "[field]": {
          "type": "keyword"
        }
      }
    }
  }
}

```




以上是关于markdown [Mapping] #elasticsearch #snippets的主要内容,如果未能解决你的问题,请参考以下文章

Elastic Search中mapping的问题

Elastic认证特训营 难点解读13——Mapping新创建后,还可以更新吗?

markdown [Mapping] #elasticsearch #snippets

ELASTIC制图等高级使用

Elastic Stack-Elasticsearch使用介绍

elastic search 索引