ES与关系型数据库的通俗比较

1、在Elasticsearch中,文档归属于一种类型(type),而这些类型存在于索引(index)中,我们可以画一些简单的对比图来类比传统关系型数据库:

Relational DB -> Databases -> Tables -> Rows -> Columns

Elasticsearch -> Indices -> Types -> Documents -> Fields

即:Elasticsearch集群可以包含多个索引(indices)(数据库),每一个索引可以包含多个类型(types)(表),每一个类型包含多个文档(documents)(行),然后每个文档包含多个字段(Fields)(列)。

例如在kibana中的Dev Tool中查询:

//查指定userId

GET /risk_merchant_his/_search
{"query":{
  "bool" : {
    "must" : [
      {
      "term" : {
        "userId" : {
          "value" : 109530,
          "boost" : 1.0
          }
        }
      }
    ],
    "adjust_pure_negative" : true,
    "boost" : 1.0
    }
  }
}

//查全量数据

GET /risk_order_his/_search
{"query":{
"bool" : {
"must" : [
{
"match_all": {

}
}

],
"adjust_pure_negative" : true,
"boost" : 1.0
}
}
}

原文地址:https://www.cnblogs.com/wzk-0000/p/12059495.html