一:elasticsearch常用操作总结
索引
搜索
mapping
分词器
1.创建索引
http://192.168.65.131:9200/smartom_index
2.查看索引:
http://192.168.65.131:9200/_cat/indices?v
3.插入数据【这样也就是说创建了一个文档为users】
http://192.168.65.131:9200/smartom_index/users/101
{
"name":"smartom",
"age":19
}
4.精确搜索
http://192.168.65.131:9200/smartom_index/_search?q=name:smartom
5.全词搜索
http://192.168.65.131:9200/smartom_index/_search
全文索引
6.全词搜索 term
term是代表完全匹配,即不进行分词器分析,文档中必须包含整个搜索的词汇
GET smartom_index/users/_search
{
"query":{
"term":{
"name":{
"value":"smartom"
}
}
}
}
7.全词搜索 match 全文搜索查询
分词查询
GET smartom_index/users/_search
{
"query": {
"match": {
"name": "我是smartom你是谁"
}
}
}
分词器analyze
8.创建一个分词器
POST _analyze
{
"analyzer":"standard",
"text":"我是smartom你是谁"
}
standard
simple
过滤器 标记器 [去掉]
9. 一个标记器【filter?】
POST _analyze
{
"tokenizer":"lowercase",
"text":"SMARTOM"
}
也可以 在tokenizer里面写 standard
10.一个过滤器:
POST _analyze
{
"tokenizer": "standard",
"filter": ["lowercase"],
"text": "我是smartom你是谁"
}
11.字符过滤器:[过滤html代码]
POST _analyze
{
"tokenizer": "standard",
"char_filter": ["html_strip"],
"text": "woshi<br><b>asdf</b>是"
}
11.停用词
13.创建一个过滤器:settings analysis analyzer 【在索引里面用来进行搜索】
PUT smartom
{
"settings": {
"analysis": {
"analyzer": {
"smartom-analyer":{
"type":"custom",
"tokenizer":"standard",
"char_filter":["html_strip"],
"filter":["lowercase"]
}
}
}
}
}
14.创建仓库:
前提指定repo路径 elasticsearch.yml
path.repo: ["/tmp/esbak"]
PUT _snapshot/mybackup
{
"type": "fs",
"settings": {
"location": "/tmp/esbak"
}
}
15.备份索引:
bak1 是备份名称 smartom_index 备份的索引名称
PUT _snapshot/mybackup/bak1?wait_for_completion=true
{
"indices": "smartom_index"
}
16.删除索引
DELETE smartom_index
17.关闭索引
POST smartom_index/_close
18.恢复索引
POST _snapshot/mybackup/bak1/_restore?wait_for_completion=true
{
"indices": "smartom_index"
}
19.查看当前插件
GET _cat/plugins
20.查看mapping当前文档 查看文档字段类型?
GET smartom_index/_mappings
21.创建mapping
[刚创建的时候]
POST /smartom_index/fulltext/_mapping
{
"properties": {
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_max_word"
}
}
}
需要导入和导出数据
删除数据之后
title 用ik分词器进行索引
PUT smartom_index
{
"mappings": {
"news":{
"properties": {
"title": {
"type":"text",
"analyzer": "ik_max_word"
}
}
}
}
}
22.修改文档中的类型?
PUT smartom_index/_mapping/users
{
"properties": {
"news": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
23.搜索建议
一:elasticsearch常用操作总结的更多相关文章
- ElasticSearch常用操作
查看某个INDEX库某个TYPE表,某个字段的分词结果 GET /${index}/${type}/${id}/_termvectors?fields=${fields_name}http://19 ...
- Elasticsearch本地环境安装和常用操作
本篇文章首发于我的头条号Elasticsearch本地环境安装和常用操作,欢迎关注我的头条号和微信公众号"大数据技术和人工智能"(微信搜索bigdata_ai_tech)获取更多干 ...
- Elasticsearch(ES)API 增删查改常用操作
常用操作 查询所有数据 POST http://192.168.97.173:27009/logstash_test_2018/doc/_search { "query": { & ...
- ElasticSearch 集群基本概念及常用操作汇总(建议收藏)
内容来源于本人的印象笔记,简单汇总后发布到博客上,供大家需要时参考使用. 原创声明:作者:Arnold.zhao 博客园地址:https://www.cnblogs.com/zh94 目录: Elas ...
- elasticsearch使用操作部分
本片文章记录了elasticsearch概念.特点.集群.插件.API使用方法. 1.elasticsearch的概念及特点.概念:elasticsearch是一个基于lucene的搜索服务器.luc ...
- Elasticsearch 常用API
1. Elasticsearch 常用API 1.1.数据输入与输出 1.1.1.Elasticsearch 文档 #在 Elasticsearch 中,术语 文档 有着特定的含义.它是指最顶 ...
- 【三】用Markdown写blog的常用操作
本系列有五篇:分别是 [一]Ubuntu14.04+Jekyll+Github Pages搭建静态博客:主要是安装方面 [二]jekyll 的使用 :主要是jekyll的配置 [三]Markdown+ ...
- php模拟数据库常用操作效果
test.php <?php header("Content-type:text/html;charset='utf8'"); error_reporting(E_ALL); ...
- Mac OS X常用操作入门指南
前两天入手一个Macbook air,在装软件过程中摸索了一些基本操作,现就常用操作进行总结, 1关于触控板: 按下(不区分左右) =鼠标左键 control+按下 ...
随机推荐
- Python学习笔记第三周
目录 一.基础概念 1.集合 集合方法 a.设置集合 b.取交集 c.取并集 d.取差集 e.判断子集 f.判断父集 g.对称差集 基本操作: a.添加 b.删除 c.discard删除 d.长度 e ...
- 【转载】 看996ICU
原文地址: https://www.jianshu.com/p/15d8726fa8a8 作者:Demisstif 来源:简书 ------------------------------------ ...
- nginx高并发下配置参数
今天下午,测试组同事模拟800个用户同时发起请求,nginx开始报错, "Too Many Open Files" 我们使用的是Dell R430服务器,2个物理CPU,每个CP ...
- c日志宏
仅供参考,不推荐 #ifdef _DEBUG #define LOGDEBUG(format, ...)\ {\ FILE *fp = fopen("nccli.log", &qu ...
- 20155219实验四 Android开发基础设计实验报告
20155219实验四 Android开发基础设计实验报告 实验内容 安装Andriod Studio并配置软件 使用Andriod Studio软件实现Hello World!+学号的小程序 实验步 ...
- ZOJ4060 Flippy Sequence(思维题)
题目链接:传送门 题目大意: 两个长度为n的二进制串s,t,每次操作可以将s串的一段区间取反.求操作exactly twice后使得s=t的方法数. 思路: 连续的尽可能长的 si ≠ ti 的区间简 ...
- 2018.4.23 pip使用
pip打包 python setup.py check 检查setup.py是不是正确,如果正确就只输出running check python setup.py dist 会将项目打包成一个ta ...
- YIT-CTF—密码学
一.哼哼 小猪生活的地方在哪里? 看题目联想到是猪圈加密 二.卢本伟 LOL我只服五五开 ๑乛◡乛๑babbababaababbababaaababaaaaaaabaaa 更具提示“五五开”,再看到这 ...
- Python 面向对象(创建类和对象,面向对象的三大特性是指:封装、继承和多态,多态性)
概念: ...
- Redis(二)持久化
Redis持久化,分为RDB方式和AOF方式,它们可以单独使用,也可以混用.Redis默认的是使用RDB方式. 一.RDB方式 1.触发快照的方式 RDB方式是在指定时间间隔内某一时间点的数据集快照. ...