当前位置:   article > 正文

ES索引字段创建及查询_es 索引字段

es 索引字段

ES索引字段创建及查询

DELETE /demo_test
PUT /demo_test
{
  "settings": {
    "number_of_shards": 1,
    "number_of_replicas": "0"
  },
  "mappings": {
    "properties": {
      "type": {
        "type": "keyword"
      },
      "name": {
        "type": "keyword"
      },
      "ip": {
        "type": "ip"
      },
      "vname": {
        "type": "keyword"
      },
      "list": {
        "type": "nested",
        "properties": {
          "id": {
            "type": "integer"
          },
          "type": {
            "type": "keyword"
          },
          "name": {
            "type": "keyword"
          }
        }
      },
      "GatewayAddress": {
        "type": "nested",
        "properties": {
          "ip": {
            "type": "ip"
          },
          "mask": {
            "type": "short"
          }
        }
      },
      "ips": {
        "type": "ip"
      },
      ,
      "time": {
        "type": "date",
        "format":"yyyy-MM-dd HH:mm:ss"
      }
    }
  }
}

POST demo_test/_doc
{"type":"type01", "name":"name01", "ip":"172.1.1.200", "vname":"vname", 
 "list":
    [
      {
         "id":1,
         "type":"xx",
         "name":"XXX"
      }
    ], 
 "GatewayAddress":[
   {
     "ip":"10.0.1.1",
     "mask":32
    },
    {
     "ip":"0.0.0.0",
     "mask":24
    }
 ], 
 "ips":["192.168.3.120", "192.168.3.121", "192.168.3.121", "192.168.3.121"],
 "time":"2020-04-17 18:04:30"
}


联查:
GET demo_test/_search
{
  "query": {
    "bool": {
        "must": [
            {
              "query_string": {
                "query": "xxx",
                "default_field": "name"
              }
            },
           {
              "nested": {
                "path": "list",
                "query": {
                  "term": {
                    "list.id": {
                      "value": 1
                    }
                  }
                }
              }
            },
            {
              "query_string": {
                "query": "vname01",
                "default_field": "vname"
              }
            },
            {
              "nested": {
                "path": "GatewayAddress",
                "query": {
                  "term": {
                    "GatewayAddress.ip": {
                      "value": "0.0.0.0"
                    }
                  }
                }
              }
            },
            {
              "term": {
                "ips":{
                  "value": "0.0.0.0"
                }
               
              }
            }
          ]
      }
  }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家自动化/article/detail/663290
推荐阅读
相关标签
  

闽ICP备14008679号