elasticsearch创建索引和查看索引及结构命令

命令

查看索引及结构:

命令: GET /索引名/_mapping?pretty

创建索引:

命令: PUT 索引名

示例:
number_of_shards:分片数量(按机器节点数量计算,创建后不能更改)
number_of_replicas:副本数量

PUT admin_log_0821
{
     
	  "settings":{
     
	    "number_of_shards":6,
      "number_of_replicas":	1
	  },
		"mappings": {
     
			"logs": {
     
				"properties": {
     
				"esCreateTime": {
     
					"type": "long"
				},
				"id": {
     
					"type": "long"
				},
				"ip": {
     
					"type": "text",
					"fields": {
     
						"keyword": {
     
							"type": "keyword",
							"ignore_above": 256
						}
					}
				},
				"uri": {
     
					"type": "text",
					"fields": {
     
						"keyword": {
     
							"type": "keyword",
							"ignore_above": 256
						}
					}
				},
				"userId": {
     
					"type": "text",
					"fields": {
     
						"keyword": {
     
							"type": "keyword",
							"ignore_above": 256
						}
					}
				},
				"userName": {
     
					"type": "text",
					"fields": {
     
						"keyword": {
     
							"type": "keyword",
							"ignore_above": 256
						}
					}
				}
			}
			}
		}
	}

基础索引示例:

{
     
  "settings": {
     
    "number_of_shards": 16,
    "number_of_replicas": 1
  },
  "mappings": {
     
    "risk_event_ads": {
     
      "dynamic": "strict",
      "properties": {
     
        "flowNo": {
     
          "type": "String",
          "index": "not_analyzed"
        },
        "elapseTime": {
     
          "type": "long"
        },
        "ipLon": {
     
          "type": "float"
        },
        "createTime": {
     
          "type": "date"
        },
        "occurTimeYear": {
     
          "type": "short"
        },
        "occurTimeMonth": {
     
          "type": "byte"
        },
        "cpuCurFreq": {
     
          "index": "not_analyzed",
          "type": "string"
        },
        "extraInfoObj": {
     
          "type": "object",
          "dynamic": true
        }
      }
    }
  }
}

crul命令: curl -XPUT “http://es地址:9200/索引名” -H ‘Content-Type: application/json’ -d’索引json’

你可能感兴趣的:(资源,学习过程,elasticsearch,索引,命令)