栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 云计算 > 云平台

ElasticSearch可视化操作【使用记录】

云平台 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ElasticSearch可视化操作【使用记录】

导入数据 1.创建索引——put 索引名字
  • author、title、id:text类型(字符串)
  • paragraphs:数组类型
PUT song
{
  "mappings": {
    "properties": {
      "author":{
        "type": "text"
      },
      "title":{
        "type": "text"
      },
      "paragraphs":{
        "index": "true",
        "type": "keyword"
      },
      "id":{
        "type": "text"
      }
    }
  }
}

执行结果

2.插入数据——put 索引/_doc/数字
PUT song/_doc/1
{
  "author": "宋太祖",
  "paragraphs": [
  "欲出未出光辣達,千山萬山如火發。",
   "須臾走向天上來,逐却殘星趕却月。"
  ],
  "title": "日詩",
  "id": "08e41396-2809-423d-9bbc-1e6fb24c0ca1"
}
查询数据 1.全局查询——GET 索引/_search
GET song/_search
{
   "query": {
        "match_all": {}
    }
}

查询结果

2.判断索引是否存在——head
GET song/_count

查询成功

查询失败

统计数据 1.分词统计

创建索引

创建索引时添加字段"fielddata": "true"

例如

PUT song
{
  "mappings": {
    "properties": {
      "author":{
        "type": "text"
      },
      "title":{
        "type": "text"
      },
      "paragraphs":{
        "analyzer": "ik_max_word",
        "type": "text",
      "fielddata": "true"
      },
      "id":{
        "type": "text"
      }
    }
  }
}

字段查询

在插入完数据后,进行分词查询

GET song/_search?pretty
{
   "size" : 0,  
    "aggs" : {   
       "messages" : {   
          "terms" : {   
            "size" : 10,
            "field" : "paragraphs"
            }  
        }  
    }
}

查询结果

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/897730.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号