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
| # 创建类型 # PUT books { "mappings": { "book":{ "properties":{ "title":{ "type":"text" }, "price":{ "type":"integer" }, "addr":{ "type":"keyword" }, "company":{ "properties":{ "name":{"type":"text"}, "company_addr":{"type":"text"}, "employee_count":{"type":"integer"} } }, "publish_date":{"type":"date","format":"yyy-MM-dd"} } } } }
# PUT books { "mappings": { "properties":{ "title":{ "type":"text" }, "price":{ "type":"integer" }, "addr":{ "type":"keyword" }, "company":{ "properties":{ "name":{"type":"text"}, "company_addr":{"type":"text"}, "employee_count":{"type":"integer"} } }, "publish_date":{"type":"date","format":"yyy-MM-dd"} } } }
# python 没有基础数据类型 ---> 对象 ---> 整形可以无限长
# 字段类型 字段数据类型 string类型:text,keyword 数字类型:byte(int8->一个字节),short(int16->2个字节),integer(int32->4个字节),long(int64-->8个字节),float(float32),double(float64) 日期类型:data 布尔类型:boolean binary类型:binary 复杂类型:object(实体,对象),nested(列表) geo类型:geo-point,geo-shape(地理位置) 专业类型:ip,competion(搜索建议) # 字段参数 ---> 字段有参数 store 值为yes表示存储,no表示不存储,默认为yes all index yes表示分析,no表示不分析,默认为true text null_value 如果字段为空,可以设置一个默认值,比如"NA"(传过来为空,不能搜索,na可以搜索) all analyzer 可以设置索引和搜索时用的分析器,默认使用的是standard分析器,还可以使用whitespace,simple。都是英文分析器 all include_in_all 默认es为每个文档定义一个特殊域_all,它的作用是让每个字段都被搜索到,如果想让某个字段不被搜索到,可以设置为false all format 时间格式字符串模式 date
# #查看books索引的mapping GET books/_mapping #获取所有的mapping GET _all/_mapping
# PUT books/_doc/1 { "title":"大头儿子小偷爸爸", "price":100, "addr":"北京天安门", "company":{ "name":"我爱北京天安门", "company_addr":"我的家在东北松花江傻姑娘", "employee_count":10 }, "publish_date":"2019-08-19" }
# 测试数据2 PUT books/_doc/2 { "title":"白雪公主和十个小矮人", "price":"99", "addr":"黑暗森里", "company":{ "name":"我的家乡在上海", "company_addr":"朋友一生一起走", "employee_count":10 }, "publish_date":"2018-05-19" }
|