显示Mapping设置与常见参数介绍

显示Mapping设置与常见参数介绍,第1张

显示Mapping设置与常见参数介绍

//设置index 为false
DELETE users
PUT users
{
  "mappings": {
    "properties": {
      "firstName":{
        "type": "text"
      },
      "lastName":{
        "type": "text"
      },
      "mobile":{
        "type": "text",
        "index": false
      }
    }
  }
}

PUT users/_doc/1
{
  "firstName":"Ruan",
  "lastName":"Yiming",
  "mobile":"12345678"
}

POST /users/_search
{
  "query": {
    "match": {
      "mobile": "12345678"
    }
  }
}

//设定Null_value
DELETE users
PUT users
{
  "mappings": {
    "properties": {
      "firstName":{
        "type": "text"
      },
      "lastName":{
        "type": "text"
      },
      "mobile":{
        "type": "keyword",
        "null_value": "NULL"
      }
    }
  } 
}

PUT users/_doc/1
{
  "firstName":"Ruan",
  "lastName":"Yiming",
  "mobile":null
}

PUT users/_doc/2
{
  "firstName":"Ruan2",
  "lastName":"Yiming2"
}

GET users/_search
{
  "query": {
    "match": {
      "mobile": "NULL"
    }
  }
}


//设置Copy to
DELETE users
PUT users
{
  "mappings": {
    "properties": {
      "firstName":{
        "type": "text",
        "copy_to": "fullName"
      },
      "lastName":{
        "type": "text",
        "copy_to": "fullName"
      }
    }
  }
}

PUT users/_doc/1
{
  "firstName":"Ruan",
  "lastName":"Yiming"
}

GET users/_search?q=fullName:(Ruan Yiming)

POST users/_search
{
  "query": {
    "match": {
      "fullName": {
        "query": "Ruan Yiming",
        "operator": "and"
      }
    }
  }
}

//数组类型
PUT users/_doc/1
{
  "name":"onebird",
  "interests":"reading"
}

GET users/_doc/1

PUT users/_doc/1
{
  "name":"onebird",
  "interests":["reading","music"]
}

POST users/_search
{
  "query": {
    "match_all": {}
  }
}

GET /users/_mapping

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5573243.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-14
下一篇 2022-12-14

发表评论

登录后才能评论

评论列表(0条)

保存