# 刪除 index
DELETE devopsdays-taipei-2023-ec-order
# 建立 Index Template
# 包含 `_meta` 資料,以及 `aliases`。
PUT _index_template/devopsdays-taipei-2023-ec-order
{
"index_patterns": [
"devopsdays-taipei-2023-ec-order*"
],
"template": {
"aliases": {
"devopsdays-taipei-2023-ec-order": {}
},
"mappings": {
"_meta": {
"version": 1,
"version_creation_date": "2023-09-26"
},
"properties": {
"currency": { "type": "keyword" },
"customer_first_name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 }} },
"customer_gender": { "type": "keyword" },
"customer_id": { "type": "keyword" },
"customer_last_name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 }} },
"order_date": { "type": "date" },
"order_id": { "type": "keyword" },
"products": {
"properties": {
"base_price": { "type": "double" },
"discount_percentage": { "type": "float" },
"quantity": { "type": "float" },
"manufacturer": { "type": "keyword" },
"tax_amount": { "type": "float" },
"product_id": { "type": "keyword" },
"category": { "type": "keyword" },
"sku": { "type": "keyword" },
"taxless_price": { "type": "double" },
"unit_discount_amount": { "type": "float" },
"min_price": { "type": "double" },
"_id": { "type": "keyword" },
"discount_amount": { "type": "float" },
"created_on": { "type": "date" },
"product_name": { "type": "text", "fields": { "keyword": { "type": "keyword", "ignore_above": 256 }} },
"price": { "type": "double" },
"taxful_price": { "type": "double" },
"base_unit_price": { "type": "double" }
}
},
"taxful_total_price": { "type": "double" },
"taxless_total_price": { "type": "double" },
"total_quantity": { "type": "float" },
"total_unique_products": { "type": "float" },
"type": { "type": "keyword" },
"user": { "type": "keyword" }
}
}
},
"priority": 100,
"version": 1,
"_meta": {
"description": "devopsdays workshop",
"version_creation_date": "2023-09-26"
}
}
# 這次我們將 Index 名字後面加上 `_v1`,用來區別這是第一版,重新將資料匯入。
PUT devopsdays-taipei-2023-ec-order_v1/_bulk
{ "index" : { "_id" : "584677" } }
{"currency":"EUR","customer_first_name":"Eddie","customer_gender":"MALE","customer_id":38,"customer_last_name":"Underwood","customer_phone":"","order_date":"2023-10-09T09:28:48+00:00","order_id":584677,"products":[{"base_price":11.99,"discount_percentage":0,"quantity":1,"manufacturer":"Elitelligence","tax_amount":0,"product_id":6283,"category":"Men's Clothing","sku":"ZO0549605496","taxless_price":11.99,"unit_discount_amount":0,"min_price":6.35,"_id":"sold_product_584677_6283","discount_amount":0,"created_on":"2016-12-26T09:28:48+00:00","product_name":"Basic T-shirt - dark blue/white","price":12,"taxful_price":12,"base_unit_price":12},{"base_price":24.99,"discount_percentage":0,"quantity":1,"manufacturer":"Oceanavigations","tax_amount":0,"product_id":19400,"category":"Men's Clothing","sku":"ZO0299602996","taxless_price":25,"unit_discount_amount":0,"min_price":11.75,"_id":"sold_product_584677_19400","discount_amount":0,"created_on":"2016-12-26T09:28:48+00:00","product_name":"Sweatshirt - grey multicolor","price":25,"taxful_price":25,"base_unit_price":25}],"taxful_total_price":37,"taxless_total_price":37,"total_quantity":2,"total_unique_products":2,"type":"order","user":"eddie"}
{ "index" : { "_id" : "584021" } }
{"currency":"EUR","customer_first_name":"Mary","customer_gender":"FEMALE","customer_id":20,"customer_last_name":"Bailey","customer_phone":"","order_date":"2023-10-08T21:59:02+00:00","order_id":584021,"products":[{"base_price":24.99,"discount_percentage":0,"quantity":1,"manufacturer":"Champion Arts","tax_amount":0,"product_id":11238,"category":"Women's Clothing","sku":"ZO0489604896","taxless_price":24.99,"unit_discount_amount":0,"min_price":11.75,"_id":"sold_product_584021_11238","discount_amount":0,"created_on":"2016-12-25T21:59:02+00:00","product_name":"Denim dress - black denim","price":24.99,"taxful_price":24.99,"base_unit_price":24.99},{"base_price":28.99,"discount_percentage":0,"quantity":1,"manufacturer":"Pyramidustries","tax_amount":0,"product_id":20149,"category":"Women's Clothing","sku":"ZO0185501855","taxless_price":28.99,"unit_discount_amount":0,"min_price":15.65,"_id":"sold_product_584021_20149","discount_amount":0,"created_on":"2016-12-25T21:59:02+00:00","product_name":"Shorts - black","price":28.99,"taxful_price":28.99,"base_unit_price":28.99}],"taxful_total_price":53.98,"taxless_total_price":53.98,"total_quantity":2,"total_unique_products":2,"type":"order","user":"mary"}
{ "index" : { "_id" : "584058" } }
{"currency":"EUR","customer_first_name":"Gwen","customer_gender":"FEMALE","customer_id":26,"customer_last_name":"Butler","customer_phone":"","order_date":"2023-10-04T22:32:10+00:00","order_id":584058,"products":[{"base_price":99.99,"discount_percentage":0,"quantity":1,"manufacturer":"Low Tide Media","tax_amount":0,"product_id":22794,"category":"Women's Shoes","sku":"ZO0374603746","taxless_price":99.99,"unit_discount_amount":0,"min_price":46.01,"_id":"sold_product_584058_22794","discount_amount":0,"created_on":"2016-12-25T22:32:10+00:00","product_name":"Boots - Midnight Blue","price":99.99,"taxful_price":99.99,"base_unit_price":99.99},{"base_price":99.99,"discount_percentage":0,"quantity":1,"manufacturer":"Oceanavigations","tax_amount":0,"product_id":23386,"category":"Women's Clothing","sku":"ZO0272202722","taxless_price":99.99,"unit_discount_amount":0,"min_price":53.99,"_id":"sold_product_584058_23386","discount_amount":0,"created_on":"2016-12-25T22:32:10+00:00","product_name":"Short coat - white/black","price":99.99,"taxful_price":99.99,"base_unit_price":99.99}],"taxful_total_price":199.98,"taxless_total_price":199.98,"total_quantity":2,"total_unique_products":2,"type":"order","user":"gwen"}
# 檢查 `taxful_total_price` 與 `taxless_total_price` 的型態
GET devopsdays-taipei-2023-ec-order/_mapping
# 重新查詢,現在已正常
GET devopsdays-taipei-2023-ec-order/_search
{
"query": {
"range": {
"taxful_total_price": {
"lte": 53
}
}
}
}