elasticsearch常用查询和注意点

此文档为笔记,主要记录一些运用过程中注意的点,适合初学者,欢迎大神提出意见:

es内置分析器:

  一段搜索字符 "Set the shape to semi-transparent by calling set_trans(5)"

  标准分析器 standard(默认) 根据 Unicode 联盟 定义的 单词边界 划分文本。删除绝大部分标点。最后,将词条小写

  set, the, shape, to, semi, transparent, by, calling, set_trans, 5

  简单分析器 simple 任何不是字母的地方分隔文本,将词条小写

  set, the, shape, to, semi, transparent, by, calling, set, trans

  空格分析器whitespace 空格的地方划分文本

  Set, the, shape, to, semi-transparent, by, calling, set_trans(5)

  语言分析器english 根据不同语言特点自动分析 比如英语如下

  set, shape, semi, transpar, call, set_tran, 5 transparent`、 `calling 和 set_trans 已经变为词根格式

查看映射: GET website/_mapping/blog

测试映射: GET website/_analyze  请求体{ "field":"字段", "text":"请求内容 no picture"}

测试映射 curl请求模式:::curl -X GET "localhost:9200/_analyze" -H 'Content-Type: application/json' -d'

{
"analyzer": "standard",
"text": "Text to analyze"
}
'

验证查询是否合法:::

GET website/blog/_validate/query 如果想查不合法的原因 加?explain参数
{
"query":{
"title":{
"match": "this"
}
}
}

查询所有的索引:::GET _validate/query?explain

索引别名:

     1 创建索引 put /my_index_v1 给索引创建别名 put /my_index_v1/_alias/my_index

     2 查看别名指向那个索引 get /*/_alias/my_index

     3 查看索引下的别名 get /my_index_v1/_alias/*

疯子在左,天才在右
原文地址:https://www.cnblogs.com/zilixiang/p/9167905.html