扩展程序加载elasticsearch-head_v0.1.4
Kibana配置
server.port: 5601
server.host: "192.168.32.17"
elasticsearch.hosts: ["http://***:***"]
elasticsearch.username: "***"
elasticsearch.password: "***"
kibana的后台启动
nohup ./kibana >> /opt/kibana.log 2>&1 &
http://192.168.32.17:5601/app/kibana
Java High Level REST Client
阿里云客户端实例
https://help.aliyun.com/document_detail/121359.html?spm=a2c4g.11186623.4.1.6af2bd30gUl4tq
keyword 与 text 映射类型的区别
将 book 字段设置为 keyword 映射 (只能精准查询, 不能分词查询,能聚合、排序)
POST /es_db/student/_search
{
"query": {
"term": {
"book": "elasticSearch入门至精通"
}
}
}
将 book 字段设置为 text 映射 (能模糊查询, 能分词查询,不能聚合、排序)
POST /es_db/student/_search
{
"query": {
"match": {
"book": "elasticSearch入门至精通"
}
}
}
索引建立
POST /es_db/_mapping/student
{
"student":{
"properties":{
"name":{
"type":"keyword"
},
"sex":{
"type":"integer"
},
"age":{
"type":"integer"
},
"book":{
"type":"text",
"analyzer":"ik_smart",
"search_analyzer":"ik_smart"
},
"address":{
"type":"text",
"analyzer":"ik_smart",
"search_analyzer":"ik_smart"
}
}
}
}
分词分析
GET _analyze
{
"analyzer": "ik_smart",
"text": "中华人民共和国人民大会堂"
}
GET _analyze
{
"analyzer": "ik_max_word",
"text": "中华人民共和国人民大会堂"
}
分词检索分析
PUT /es_db/student/1
{
"name": "Jack",
"sex": 1,
"age": 25,
"book": "java入门至精通",
"address": "广州小蛮腰"
}
java入门至精通:java、入门、至、精通
##无法查到
POST /es_db/student/_search
{
"query": {
"match": {
"book": "入"
}
}
}
##可以查到
POST /es_db/student/_search
{
"query": {
"match": {
"book": "入门"
}
}
}
##可以查到
POST /es_db/student/_search
{
"query": {
"match": {
"book": "至"
}
}
}
#可以查到
POST /es_db/student/_search
{
"query": {
"match": {
"book": "入门精通"
}
}
}
#可以查到
POST /es_db/student/_search
{
"query": {
"match": {
"book": "入门至精通"
}
}
}
Ik分词器在阿里云的配置
https://help.aliyun.com/document_detail/137928.html?spm=a2c4g.11186623.6.601.5a47104elzPfoo
index_not_found_exception的解决
出现index_not_found_exception错误的解决方式,建立该索引,然后继续运行