mapping——参数——index

index

The index option controls whether field values are indexed. It accepts true or false and defaults to true. Fields that are not indexed are not queryable.

index选项控制是否为字段值建立索引它接受TRUE或FALSE,默认为TRUE。未编制索引的字段不可查询。
 
 1 PUT gg/_doc/_mapping
 2 {
 3   "properties":{
 4     "employee-id":{
 5       "type":"keyword",
 6       "index": false   #设置该字段不能被索引   所以该字段的值可以被存储,但是不能被查询
 7     }
 8   }
 9 }
10 
11 PUT gg/_doc/12
12 {
13   "employee-id":"gas"
14 }
15 
16 GET gg/_search   #可以查到该索引下所有的值24 
25 
26 GET gg/_search   #报错
27 {
28   "query": {
29     "match": {
30       "employee-id": "gas"
31     }
32   }
33 }

             "type": "illegal_argument_exception",
            "reason": "Cannot search on field [employee-id] since it is not indexed."

posted on 2019-10-12 10:31  浅蓝色星光  阅读(458)  评论(0编辑  收藏  举报