2、elasticsearch_course_如何进行搜索

在 Elasticsearch 中的搜索中,有两类搜索:

  • queries 检索
    • 全文检索
  • aggregations 聚合
    • 数据统计和分析

我们有时也可以结合 query 及 aggregation一起使用,比如我们可以先对文档进行搜索然后在进行 aggregation:

已经建立了 twitter 的index(索引)
1.指定索引全文档检索
  GET   /twitter/_search
2.不指定索引,默认查找所有的index,默认返回默认个数的10个
3.多个索引查询
  GET /twitter,blog/_search
4.通配符和 排除
POST /index*,-index3/_search
5.结果分析
{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "twitter",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "user" : "makuo",
          "uid" : 1,
          "city" : "shandong",
          "province" : "Guangdong",
          "country" : "China",
          "name" : "makuo"
        }
      },
      {
        "_index" : "twitter",
        "_type" : "_doc",
        "_id" : "eJEIdX0BPy_Vj1s24c-0",
        "_score" : 1.0,
        "_source" : {
          "name" : "makuo",
          "age" : 18,
          "gender" : "male"
        }
      }
    ]
  }
}

上一篇:git无法pull仓库refusing to merge unrelated histories (拒绝合并不相关仓库)


下一篇:git fatal: refusing to merge unrelated histories