索引index
这个参数可以控制字段应该怎样建索引,怎样查询。它有以下三个可用值:
· no: 不把此字段添加到索引中,也就是不建索引,此字段不可查询
· not_analyzed:将字段的原始值放入索引中,作为一个独立的term,它是除string字段以外的所有字段的默认值。
· analyzed:string字段的默认值,会先进行分析后,再把分析的term结果存入索引中。
那么如果不需要的值,直接在mapping中设置为no就可以了。其它信息参考:store 和 _source field
简要说明:store就是把这个字段单独存储,默认是不存储的,默认存储的是 _source ,只有设置了才会存储,比如,有一个mapping有三个字段,title,subject,content,其中title,subject比较小,而content非常非常大,如果,你的查询结果只需要title,subject而不需要content时,把title,subject单独存储,可以节省很多时间
{
"mappings": {
"index": {
"_all": {
"enabled": false
},
"properties": {
"ip": {
"type": "string",
"store":true
}
}
}
}
}
查询语句:
{
"query": {
"match": {
"ip": "192.168.1.53"
}
}
}
结果:
{
- "took": 6,
- "timed_out": false,
index:no
{
"mappings": {
"index": {
"_all": {
"enabled": false
},
"properties": {
"ip": {
"type": "string",
"index":"no",
"store":true
}
}
}
}
}
查询语句:
{
"query": {
"match": {
"ip": "192.168.1.53"
}
}
}
结果:
{
- "took": 5,
- "timed_out": false,