zoukankan      html  css  js  c++  java
  • 自定义mapping与常见参数





    PUT test
    {
      "mappings": {
        "dynamic": true,
        "properties": {
          "firstname": {
            "type": "text",
            "copy_to": "fullname"
          },
          "lastname": {
            "type": "text",
            "copy_to": "fullname"
          }
        }
      }
    }
    
    PUT test/_doc/1
    {
      "firstname":"zhang"
    }
    
    PUT test/_doc/2
    {
      "lastname":"san"
    }
    
    # 搜索有结果,两者是or的关系
    GET test/_search?q=fullname:(zhang san)
    
    # 搜索没有结果,两者and的关系
    GET test/_search
    {
      "query": {
        "term": {
          "fullname": {
            "value": "zhang san"
          }
        }
      }
    }
    
    DELETE test
    

    
    #设置 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
    
    
  • 相关阅读:
    软工实践寒假作业(2/2)
    软工实践寒假作业(1/2)
    个人作业——软件工程实践总结&个人技术博客
    个人技术总结——postman的接口请求
    个人作业——软件评测
    结对第二次作业——某次疫情统计可视化的实现
    结对第一次—疫情统计可视化(原型设计)
    软工实践寒假作业(2/2)
    软工实践寒假作业(1/2)
    个人作业——软件工程实践总结&个人技术博客
  • 原文地址:https://www.cnblogs.com/sanduzxcvbnm/p/14513139.html
Copyright © 2011-2022 走看看