zoukankan      html  css  js  c++  java
  • ES基础(十一)显式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"
    }
    
    PUT users/_doc/1
    {
      "name":"twobirds",
      "interests":["reading","music"]
    }
    
    POST users/_search
    {
      "query": {
            "match_all": {}
        }
    }
    
    GET users/_mapping

    本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/14195099.html

  • 相关阅读:
    poj3041——最小点覆盖
    高斯消元
    hdu1704——floyd
    poj2594——最小路径覆盖
    POJ3020 二分图匹配——最小路径覆盖
    我的老博客
    [ZJOI2015]幻想乡战略游戏 动态点分治
    HDU 5737 Differencia set + 主席树
    HDU
    HDU
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14195099.html
Copyright © 2011-2022 走看看