• Elasticsearch初探


    •  elasticsearch中的概念同传统数据库的类比如下:

    Relational DB -> Databases -> Tables -> Rows -> Columns
    Elasticsearch -> Indices -> Types -> Documents -> Fields

    关系数据库     ⇒ 数据库 ⇒ 表    ⇒ 行    ⇒ 列(Columns)
    Elasticsearch  ⇒ 索引   ⇒ 类型  ⇒ 文档  ⇒ 字段(Fields)
    • 导入数据API:
    curl -XPOST 'http://localhost:9200/prd/xjb3/_bulk' --data-binary @last.json

     

    • last.json文件里面的数据格式形如:<数据地址:http://files.cnblogs.com/files/kevin-yuan/elasticsearchJsonData.zip>
    {"index":{"_id":"1"}}
    {"account_number":1,"balance":39225,"firstname":"Amber","lastname":"Duke","age":32,"gender":"M","address":"880 Holmes Lane","employer":"Pyrami","email":"amberduke@pyrami.com","city":"Brogan","state":"IL"}
    {"index":{"_id":"6"}}
    {"account_number":6,"balance":5686,"firstname":"Hattie","lastname":"Bond","age":36,"gender":"M","address":"671 Bristol Street","employer":"Netagy","email":"hattiebond@netagy.com","city":"Dante","state":"TN"}
    {"index":{"_id":"13"}}
    {"account_number":13,"balance":32838,"firstname":"Nanette","lastname":"Bates","age":28,"gender":"F","address":"789 Madison Street","employer":"Quility","email":"nanettebates@quility.com","city":"Nogal","state":"VA"}
    • 排序查询API:
    http://localhost:9200/prd/xjb3/_search?sort=balance:desc
    • 指定返回条数:加上size=N即可
    http://localhost:9200/prd/xjb3/_search?sort=amount:desc&size=100

    资料:

    [1] http://learnes.net/index.html  文档github地址:https://github.com/GavinFoo/elasticsearch-definitive-guide

  • 相关阅读:
    计算机网络
    一行代码实现字符串逆序输出
    移动前端开发初涉篇【2014/03/25】
    小识闭包【2013/07/18】
    [转载]IE6Bug之躲猫猫【2013/10/29】
    关于maven仓库镜像
    关于spring resttemplate超时设置
    关于springboot访问多个mysql库
    关于Java基础类型自动装箱(autoboxing)
    关于Java(JDBC连接数据库)
  • 原文地址:https://www.cnblogs.com/kevin-yuan/p/5532402.html
Copyright © 2020-2023  润新知