# 需要注意,新增mapping字段是允许的
# 但是如果是修改,必须删除索引,重新索引
# 即一个字段的类型修改以后,那么该字段的所有数据都需要重新索引
# 创建索引
PUT my_index
# 创建索引mapping
POST my_index/my_child/_mapping
{
"my_ child": {
"_all": {
"enabled": false
},
"properties": {
"source": {
"type": "string"
},
"content": {
"type": "string",
"index": "analyzed",
"analyzer": "ik_max_word"
},
"id": {
"type": "integer"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
"create_time": {
"type": "date",
"format":"YYYY-MM-dd HH:mm:ss"
}
}
}
}
# 新增索引mapping
POST my_index/my_child/_mapping
{
"my_child": {
"properties": {
"age":{
"type": "integer"
},
"work_exp":{
"type": "integer"
},
"level1":{
"type": "string",
"index": "analyzed",
"analyzer": "ik_max_word"
},
"level2":{
"type": "string",
"index": "analyzed",
"analyzer": "ik_max_word"
},
"level3":{
"type": "string",
"index": "analyzed",
"analyzer": "ik_max_word"
}
}
}
}
# 查询索引mapping
GET my_index/my_child/_mapping
# 删除索引
DELETE my_index
# 查询内容
GET /my_index/my_child/_search
{
"from": 0,
"size": 10,
"query": {
"bool": {
"must": {
"match": {
"title": "百度"
}
},
"filter": [
{
"range": {
"age": {
"lte": "30"
}
}
},
{
"range": {
"work_exp": {
"gte": "5"
}
}
}
]
}
},
"highlight": {
"fields": {
"title": {}
}
}
}
GET my_index/my_child/_search
{
"query": {
"bool": {
"must": [
{ "match": { "content": "宋建民" }},
{ "match": { "id": "43049" }}
]
}
}
}
GET my_index/my_child/_search
{
"from": 0,
"size": 10,
"query": {
"match": {
"title": "百度"
}
},
"highlight": {
"fields": {
"title": {}
}
}
}
elasticsearch 创建索引
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- 1、创建索引语法 例如: 2、修改索引 将shard副本从0变成1 3、删除索引 DELETE /my_index...
- 环境:python3.5支持包:pymysqlelasticsearch_dsl 安装 elasticsearch...