沙师弟,师父的充电器掉了

es 5.2 数值类型与keyword做termquery

匿名 | 发布于2019年12月27日 | 阅读数:2768

对10w的文档
文档中两个字段 一个类型是keyword另一个是long
做term查询 没有must什么其他的东西
profile结果如下
数值类型会快????
 
 
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 110002,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[DpRRXv7CQnazXxg_Lh_1Dg][keywordtest][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "BooleanQuery",
                "description" : "+(ConstantScore(fieldNumber:[10000 TO 10000]))^0.0 #(ConstantScore(*:*))^0.0",
                "time" : "22.92261400ms",
                "breakdown" : {
                  "score" : 0,
                  "build_scorer_count" : 9,
                  "match_count" : 0,
                  "create_weight" : 28385,
                  "next_doc" : 22685169,
                  "match" : 0,
                  "create_weight_count" : 1,
                  "next_doc_count" : 110011,
                  "score_count" : 0,
                  "build_scorer" : 99039,
                  "advance" : 0,
                  "advance_count" : 0
                },
                "children" : [
                  {
                    "type" : "BoostQuery",
                    "description" : "(ConstantScore(fieldNumber:[10000 TO 10000]))^0.0",
                    "time" : "3.443096000ms",
                    "breakdown" : {
                      "score" : 0,
                      "build_scorer_count" : 9,
                      "match_count" : 0,
                      "create_weight" : 7477,
                      "next_doc" : 3309273,
                      "match" : 0,
                      "create_weight_count" : 1,
                      "next_doc_count" : 110011,
                      "score_count" : 0,
                      "build_scorer" : 16325,
                      "advance" : 0,
                      "advance_count" : 0
                    },
                    "children" : [
                      {
                        "type" : "",
                        "description" : "fieldNumber:[10000 TO 10000]",
                        "time" : "0.01940100000ms",
                        "breakdown" : {
                          "score" : 0,
                          "build_scorer_count" : 6,
                          "match_count" : 0,
                          "create_weight" : 1214,
                          "next_doc" : 7868,
                          "match" : 0,
                          "create_weight_count" : 1,
                          "next_doc_count" : 302,
                          "score_count" : 0,
                          "build_scorer" : 10010,
                          "advance" : 0,
                          "advance_count" : 0
                        }
                      }
                    ]
                  },
                  {
                    "type" : "BoostQuery",
                    "description" : "(ConstantScore(*:*))^0.0",
                    "time" : "8.848347000ms",
                    "breakdown" : {
                      "score" : 0,
                      "build_scorer_count" : 9,
                      "match_count" : 0,
                      "create_weight" : 3050,
                      "next_doc" : 0,
                      "match" : 0,
                      "create_weight_count" : 1,
                      "next_doc_count" : 0,
                      "score_count" : 0,
                      "build_scorer" : 6106,
                      "advance" : 8729170,
                      "advance_count" : 110011
                    },
                    "children" : [
                      {
                        "type" : "MatchAllDocsQuery",
                        "description" : "*:*",
                        "time" : "2.964521000ms",
                        "breakdown" : {
                          "score" : 0,
                          "build_scorer_count" : 9,
                          "match_count" : 0,
                          "create_weight" : 704,
                          "next_doc" : 0,
                          "match" : 0,
                          "create_weight_count" : 1,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "build_scorer" : 2478,
                          "advance" : 2851318,
                          "advance_count" : 110011
                        }
                      }
                    ]
                  }
                ]
              }
            ],
            "rewrite_time" : 51252,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time" : "10.26371700ms",
                "children" : [
                  {
                    "name" : "TotalHitCountCollector",
                    "reason" : "search_count",
                    "time" : "3.861015000ms"
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}
已邀请:
匿名用户

匿名用户

赞同来自:

  },
  "hits" : {
    "total" : 110002,
    "max_score" : 0.0,
    "hits" : [ ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[Q0tFE--VQb6e5FplV49uLg][keywordtest][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "BooleanQuery",
                "description" : "+(ConstantScore(fieldKeyword:10000))^0.0 #(ConstantScore(*:*))^0.0",
                "time" : "62.45016700ms",
                "breakdown" : {
                  "score" : 0,
                  "build_scorer_count" : 3,
                  "match_count" : 0,
                  "create_weight" : 91950,
                  "next_doc" : 61706316,
                  "match" : 0,
                  "create_weight_count" : 1,
                  "next_doc_count" : 110005,
                  "score_count" : 0,
                  "build_scorer" : 541892,
                  "advance" : 0,
                  "advance_count" : 0
                },
                "children" : [
                  {
                    "type" : "BoostQuery",
                    "description" : "(ConstantScore(fieldKeyword:10000))^0.0",
                    "time" : "23.01265400ms",
                    "breakdown" : {
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "match_count" : 0,
                      "create_weight" : 28035,
                      "next_doc" : 22709907,
                      "match" : 0,
                      "create_weight_count" : 1,
                      "next_doc_count" : 110005,
                      "score_count" : 0,
                      "build_scorer" : 164703,
                      "advance" : 0,
                      "advance_count" : 0
                    },
                    "children" : [
                      {
                        "type" : "TermQuery",
                        "description" : "fieldKeyword:10000",
                        "time" : "9.629793000ms",
                        "breakdown" : {
                          "score" : 0,
                          "build_scorer_count" : 3,
                          "match_count" : 0,
                          "create_weight" : 5028,
                          "next_doc" : 9388262,
                          "match" : 0,
                          "create_weight_count" : 1,
                          "next_doc_count" : 110005,
                          "score_count" : 0,
                          "build_scorer" : 126494,
                          "advance" : 0,
                          "advance_count" : 0
                        }
                      }
                    ]
                  },
                  {
                    "type" : "BoostQuery",
                    "description" : "(ConstantScore(*:*))^0.0",
                    "time" : "16.73188800ms",
                    "breakdown" : {
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "match_count" : 0,
                      "create_weight" : 8029,
                      "next_doc" : 0,
                      "match" : 0,
                      "create_weight_count" : 1,
                      "next_doc_count" : 0,
                      "score_count" : 0,
                      "build_scorer" : 14305,
                      "advance" : 16599545,
                      "advance_count" : 110005
                    },
                    "children" : [
                      {
                        "type" : "MatchAllDocsQuery",
                        "description" : "*:*",
                        "time" : "5.430918000ms",
                        "breakdown" : {
                          "score" : 0,
                          "build_scorer_count" : 3,
                          "match_count" : 0,
                          "create_weight" : 1126,
                          "next_doc" : 0,
                          "match" : 0,
                          "create_weight_count" : 1,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "build_scorer" : 3713,
                          "advance" : 5316070,
                          "advance_count" : 110005
                        }
                      }
                    ]
                  }
                ]
              }
            ],
            "rewrite_time" : 85234,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time" : "15.60589600ms",
                "children" : [
                  {
                    "name" : "TotalHitCountCollector",
                    "reason" : "search_count",
                    "time" : "5.316156000ms"
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

xiaoyanghapi - Elasticsearch 爱好者

赞同来自:

5.2版本的ES当数据量增加到一定数量之后term keyword字段一定会比数值类型要快,我记得数字类型在ES5.2里边是kd-tree结构,之后某个版本改为了bkd-tree,一定程度上提升了数值类型的查询效率。

要回复问题请先登录注册