zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    java根据汉字获取全拼和首字母
    SQL 增加或删除一列
    C#实现WinForm传值实例解析
    C# 静态类与非静态类、静态成员的区别分析
    c# 面相对象1-概括
    c# 面相对象2-之封装性
    c# 面相对象3-之继承性
    面向对象基础知识(含义、修饰符、三大特性)
    c# 面相对象4-多态性
    用集合求平均分
  • 原文地址:https://www.cnblogs.com/kevin-yuan/p/5532402.html
Copyright © 2011-2022 走看看