Elasticsearch 索引
索引删除,更新
#查看全部索引
GET _cat/indices#查看索引结构
GET /inspection#删除索引
DELETE /lib# 原子修改别名
#索引 my_index_v1 移除别名 my_index
#索引 my_index_v2 添加别名 my_index
POST /_aliases
{"actions": [{ "remove": { "index": "my_index_v1", "alias": "my_index" }},{ "add": { "index": "my_index_v2", "alias": "my_index" }}]
}#索引 my_index_v1 添加别名 my_index
PUT /my_index_v1/_alias/my_index#数据在索引之间迁移
POST _reindex
{"source": {"index": "my_index_v1"},"dest": {"index": "my_index_v2"}
}
mappings 创建索引
#创建索引
/*
settings.number_of_shards 分片数
settings.number_of_replicas 副本
mappings.[?] 文档名?
mappings.[].properties 字段属性
*/PUT /lib
{"settings": {"number_of_shards": 3,"number_of_replicas": 0},"mappings": {"user": {"properties": {"name": {"type": "text"},"address": {"type": "text"}}}}
}#定义字段
long类型
"administrationId" : {"type" : "long"
},
nalyzer 指定ik分词器
"administrationName" : {"type" : "text","analyzer" : "ik_max_word"
},
keyword 不分词,搜索时需要匹配完整的值
"categoryAlias" : {"type" : "keyword"
},
keyword不分词,ik分词器
"firstCateName" : {"type" : "text","fields" : {"keyword" : {"type" : "keyword","ignore_above" : 256}},"analyzer" : "ik_max_word","fielddata" : true
},
text ⽤于全⽂索引,搜索时会自动使用分词器进⾏分词再匹配
"administrationName" : {"type" : "text"
}
/*
city 字段用于全文本检索;city.raw用于排序与聚合
ignore_above:超过256的字符会被存储,但不会被索引,所以查询内容超过上限不查询
fielddata:text字段查询时内存中的数据结构,如果对text类型字段聚合和排序就需要开启
*/
"city" : {"type" : "text","fields" : {"raw" : {"type" : "keyword","ignore_above" : 256}},"analyzer" : "ik_max_word","fielddata" : true
}使用
{"query": {"match": {"city": "york" }},"sort": {"city.raw": "asc" },"aggs": {"Cities": {"terms": {"field": "city.raw" }}}
}时间类型
"notificationDate" : {"type" : "date","format" : "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis"
},
#新增字段
PUT /twitter/_mapping/my_doc
{"properties": {"email": {"type": "keyword"}}
}#新增字段
PUT /my_index/_mapping/my_doc
{"properties": {"name": {"properties": {"last": {"type": "text"}}},"user_id": {"type": "keyword","ignore_above": 100 }}
}
settings 分词器
停用词
"filter" : {"jt_tfr" : {"type" : "stop","stopwords" : [" "]}
},{"settings": {"index": {"number_of_shards": "3","number_of_replicas": "0","max_result_window" : "1000000","analysis" : {"filter" : {"jt_tfr" : {"type" : "stop","stopwords" : [" "]},"jt_sfr" : {"type" : "synonym","synonyms_path" : "analysis/synonyms.txt"}},"analyzer" : {"ik_smart" : {"type" : "ik_smart","use_smart" : "true"},"ik_max_word" : {"type" : "ik_max_word","use_smart" : "false"},"jt_cn" : {"filter" : ["jt_tfr","jt_sfr"],"char_filter" : ["jt_cfr"],"type" : "custom","use_smart" : "true","tokenizer" : "ik_smart"}},"char_filter" : {"jt_cfr" : {"type" : "mapping","mappings" : ["| => \\|"]}}}}},"mappings": {}
}
keyword
#创建索引,排序字段为keyword,使用keyword 不分词,可排序可聚合
PUT /lib
{"settings": {"number_of_shards": 3,"number_of_replicas": 0},"mappings": {"user": {"properties": {"name": {"type": "text"},"address": {"type": "text"},"age": {"type": "integer"},"interests": {"type": "text","fields": {"raw": {"type": "keyword"}},"fielddata": true},"birthday": {"type": "date"}}}}
}# 排序
GET lib/user/_search
{"sort": [{"interests.raw": {"order": "desc"}}]
}#聚合
POST /lib/user/_search
{"size": 0,"aggs": {"agg_age": {"terms": {"field": "interests.raw"}}}
}#分词分析
GET /lib/_analyze
{"field": "interests","text": "喝水跑步"
}
#keyword 类型
GET /lib/_analyze
{"field": "interests.raw","text": "喝水跑步"
}
Elasticsearch 索引相关推荐
- elasticsearch 索引 red 状态恢复 green
ES集群状态.节点.索引及基本查询 一.elasticsearch 索引 red 状态恢复 green 错误原因 由于CPU占用过高或者有部分节点的分片不可用,未被分配: 解决: 重新分配未被分配的分 ...
- Elasticsearch索引生命周期管理方案
点击上方蓝色"方志朋",选择"设为星标" 回复"666"获取独家整理的学习资料! 一.前言 在 Elasticsearch 的日常中,有很多 ...
- python将ElasticSearch索引数据读入pandas dataframe实战
python将ElasticSearch索引数据读入pandas dataframe实战 # 导入基础包和库 import pandas as pdpd.set_option('display.max ...
- Elasticsearch索引(company)_Centos下CURL增删改
目录 返回目录:http://www.cnblogs.com/hanyinglong/p/5464604.html 1.Elasticsearch索引说明 a. 通过上面几篇博客已经将Elastics ...
- Elasticsearch索引原理
最近在参与一个基于Elasticsearch作为底层数据框架提供大数据量(亿级)的实时统计查询的方案设计工作,花了些时间学习Elasticsearch的基础理论知识,整理了一下,希望能对Elastic ...
- elasticsearch 索引_Elasticsearch系列---索引管理
概要 Elasticsearch让索引创建变得非常简单,只要索引一条新的数据,索引会自动创建出来,但随着数据量的增加,我们开始有了索引优化和搜索优化的需求之后,就会发现自动创建的索引在某些方面不能非常 ...
- elasticsearch索引结构和配置优化
elasticsearch索引结构和配置简单调优. 1.搜索时对特定字段设置更高权值,以弱化相关性低的字段 例如:我们在搜索时认为标题对我们更重要就可以对标题提高匹配权重 boolQuery.must ...
- sql server cdc 清理_基于CDC技术的ElasticSearch索引同步机制
概述 ElasticSearch作为一个基于Lucene的搜索引擎被广泛应用于各种应用系统,比如电商.新闻类.咨询类网站.在使用ElasticSearch开发应用的过程中,一个非常重要的过程是将数据导 ...
- ElasticSearch-Hadoop:从Hadoop到ElasticSearch索引产品视图计数和客户顶部搜索查询
这篇文章涵盖了如何使用ElasticSearch-Hadoop从Hadoop系统读取数据并在ElasticSearch中对其进行索引. 它涵盖的功能是在最近n天中为每个客户的产品浏览量计数和热门搜索查 ...
- delphi报列表索引越界怎么处理_图解Elasticsearch索引机制,此篇带你领悟新世界...
前言 随着Elastic的上市,ELK不仅在互联网大公司得到长足的发展,而且在各个中小公司都得到非常广泛的应用,甚至连"婚庆网站"都开始使用Elasticsearch了.随之而来的 ...
最新文章
- pyQt 每日一练习 -- 登录框
- EPICenter: 用户管理
- 全网最详细的Xshell或SecureCRT下spark-shell里出现无法退格或者删除的问题现象的解决办法(图文详解)...
- 若依微服务版新建业务模块后提示找不到mapper的解决方法
- BestCoder Round #4 前两题 hdu 4931 4932
- mysql etl工具有哪些_常见ETL工具一览,你知多少?
- ThinkPHP6项目基操(6.数据库Db操作)
- dpg learning 和q_深度学习和强化学习之间的差别有多大?
- python数据驱动登录_python之数据驱动ddt操作(方法三)
- 什么是BI(Business Intelligence
- matlab拟合曲线poly交点,matlab 离散曲线求交点
- 如何用VBA寻找指定区域中的第一个非空单元格
- 最短路径(图论-北京地铁线路查询)
- Flink SQL Client初探
- 夏令时到底是个什么东西?
- linux奶瓶安装方法,ubuntu系统下怎么安装奶瓶
- VUE基础API总结
- ADAS高级辅助驾驶视觉系统(Advanced Driver Assistant System)
- 怎么解决java.lang.NoClassDefFoundError错误 ,以及类的加载机制
- 会话空闲时间已超过限度
热门文章
- 如何学计算机打字,新手学习计算机打字全文阅读
- JAVA-循序结构、选择结构
- win7资源管理器总是崩溃
- HP笔记本装XP,‘基本系统设备’驱动的安装
- 辰视冯良炳博士作为专家出席演讲的2021视觉系统设计会议圆满闭幕
- 【图像去模糊】SDWNet: A Straight Dilated Network with Wavelet Transformation for image Deblurring
- 迅捷PDF转换器怎样将PDF文件转换为HTML网页
- 关于数据库中存储密码的加密
- Android push到/system/app下,导致找不到so文件,抛出java.lang.UnsatisfiedLinkError的原因分析和解决方案
- 运营必备九大互联网思维