# es-demo **Repository Path**: null_631_9084/es-demo ## Basic Information - **Project Name**: es-demo - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-02-20 - **Last Updated**: 2021-02-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 刘楠 2021-2-20 ## ES建立索引 * 初始化索引 如 PUT请求,ES地址/索引名称 aliases 索引别名 setting 索引的配置 mappings 映射 * **date类型特别说明-必须是这样的** ```json "loadingTime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" }, ``` * **~~错误的~~** ```json yyyy-MM-dd HH:mm:ss.SSS ``` * **text兼容keywords**-同时支持模糊与精确 ```json "customerName": { "type": "text", "fields": { "raw": { "type": "keyword", "null_value": "" } } } ``` * 初始化 ```json PUT http://10.83.80.31:9200/vts_cargo_order /*下面是body*/ { "aliases": { "ecs_vts_cargo_order": {} }, "settings": { "index": { "refresh_interval": "5s", "number_of_shards": "1", "translog": { "flush_threshold_size": "2gb", "sync_interval": "60s", "durability": "async" }, "max_inner_result_window": "100000", "merge": { "scheduler": { "max_thread_count": "8" }, "policy": { "floor_segment": "16mb" } }, "max_result_window": "100000", "priority": "1000", "number_of_replicas": "2" } }, "mappings": { "ecs_vts_cargo_order": { "dynamic": "false", "properties": { "userId": { "type": "long" }, "customerName": { "type": "text", "fields": { "raw": { "type": "keyword", "null_value": "" } } }, "companyNo": { "type": "keyword" }, "companyName": { "type": "text", "fields": { "raw": { "type": "keyword", "null_value": "" } } }, "needCarNumber": { "type": "integer" }, "cancelStatus": { "type": "keyword" }, "inquiryStatus": { "type": "keyword" }, "confirmTime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" }, "customerRemark": { "type": "text", "fields": { "raw": { "type": "keyword", "null_value": "" } } }, "cancelTime": { "type": "date", "format": "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis" }, "orderRemark": { "type": "text", "fields": { "raw": { "type": "keyword", "null_value": "" } } }, ... "demandOrderDetails": { "properties": { "id": { "type": "long" }, "cargoOrderId": { "type": "long" }, "cargoOrderCode": { "type": "keyword" }, "demandOrderCode": { "type": "keyword" }, ... ``` * 获取索引 ```json GET http:/x.x.x.x:9200/vts_cargo_order ``` * 删除索引 ```json /*删除索引*/ DELETE http://x.x.x.x:9200/vts_cargo_order /*删除别名*/ DELETE http://x.x.x.x:9200/ecs_vts_cargo_order ``` **建议更新字段映射关系时,先删除索引,再重新初始化** * **只更新索引(限添加字段)** ```json PUT http://x.x.x.x:9200/vts_order_basic/_mapping/ecs_vts_order_basic /*BODY*/ { "properties": { "arrivalMakeType": { "type": "keyword" }, "bidPromote": { "type": "text" }, "businessType": { "type": "keyword" }, "cancelCause": { "type": "text", "index": false } .... } } ```