码迷,mamicode.com
首页 > 其他好文 > 详细

es 的搜索

时间:2019-11-12 13:10:53      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:dram   ant   exception   测试   mys   ges   通配符   搜索   etop   

kibana语言查询

q指定查询语句

df默认字段,不指定时

sort排序/from和size用于分页

profile可以查看查询是如何倍执行的

查询title的值等于2012 的数据

GET /movies/_search?q=2012&df=title
{
  "profile": "true"
}


{
  "took" : 84,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,   2条数据
      "relation" : "eq"
    },
    "max_score" : 11.303033,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "72378",
        "_score" : 11.303033,
        "_source" : {
          "title" : "2012",
          "@version" : "1",
          "id" : "72378",
          "genre" : [
            "Action",
            "Drama",
            "Sci-Fi",
            "Thriller"
          ],
          "year" : 2009
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "105254",
        "_score" : 5.2497,
        "_source" : {
          "title" : "Crystal Fairy & the Magical Cactus and 2012",
          "@version" : "1",
          "id" : "105254",
          "genre" : [
            "Adventure",
            "Comedy"
          ],
          "year" : 2013
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "TermQuery",  使用的查询插件
                "description" : "title:2012",   查询条件
                "time_in_nanos" : 3407330,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 0,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 511430,
                  "match" : 0,
                  "next_doc_count" : 3,
                  "score_count" : 2,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 81786,
                  "build_scorer_count" : 5,
                  "create_weight" : 807809,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 2006294
                }
              }
            ],
            "rewrite_time" : 12151,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 1162515,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 163761
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  不指定字段范查询,查询值是2012 的数据

GET /movies/_search?q=2012
{
  "profile": "true"
}


{
  "took" : 12,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 219,   搜到219个结果
"relation" : "eq" }, "max_score" : 11.303033, "hits" : [ { "_index" : "movies", "_type" : "_doc", "_id" : "72378", "_score" : 11.303033, "_source" : { "title" : "2012", "@version" : "1", "id" : "72378", "genre" : [ "Action", "Drama", "Sci-Fi", "Thriller" ], "year" : 2009 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "2012", "_score" : 8.778942, "_source" : { "title" : "Back to the Future Part III", "@version" : "1", "id" : "2012", "genre" : [ "Adventure", "Comedy", "Sci-Fi", "Western" ], "year" : 1990 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "105254", "_score" : 5.2497, "_source" : { "title" : "Crystal Fairy & the Magical Cactus and 2012", "@version" : "1", "id" : "105254", "genre" : [ "Adventure", "Comedy" ], "year" : 2013 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "89745", "_score" : 1.0, "_source" : { "title" : "Avengers, The", "@version" : "1", "id" : "89745", "genre" : [ "Action", "Adventure", "Sci-Fi", "IMAX" ], "year" : 2012 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "91483", "_score" : 1.0, "_source" : { "title" : "Bullet to the Head", "@version" : "1", "id" : "91483", "genre" : [ "Action", "Crime", "Film-Noir" ], "year" : 2012 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "91485", "_score" : 1.0, "_source" : { "title" : "Expendables 2, The", "@version" : "1", "id" : "91485", "genre" : [ "Action", "Adventure" ], "year" : 2012 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "91500", "_score" : 1.0, "_source" : { "title" : "The Hunger Games", "@version" : "1", "id" : "91500", "genre" : [ "Action", "Adventure", "Drama", "Sci-Fi", "Thriller" ], "year" : 2012 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "91529", "_score" : 1.0, "_source" : { "title" : "Dark Knight Rises, The", "@version" : "1", "id" : "91529", "genre" : [ "Action", "Adventure", "Crime", "IMAX" ], "year" : 2012 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "91535", "_score" : 1.0, "_source" : { "title" : "Bourne Legacy, The", "@version" : "1", "id" : "91535", "genre" : [ "Action", "Adventure", "Drama", "Thriller", "IMAX" ], "year" : 2012 } }, { "_index" : "movies", "_type" : "_doc", "_id" : "91842", "_score" : 1.0, "_source" : { "title" : "Contraband", "@version" : "1", "id" : "91842", "genre" : [ "Action", "Crime", "Drama", "Thriller" ], "year" : 2012 } } ] }, "profile" : { "shards" : [ { "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]", "searches" : [ { "query" : [ { "type" : "DisjunctionMaxQuery", "description" : "(title.keyword:2012 | id.keyword:2012 | year:[2012 TO 2012] | genre:2012 | @version:2012 | @version.keyword:2012 | id:2012 | genre.keyword:2012 | title:2012)", "time_in_nanos" : 5403323, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 0, "set_min_competitive_score" : 0, "next_doc" : 893570, "match" : 0, "next_doc_count" : 223, "score_count" : 219, "compute_max_score_count" : 0, "compute_max_score" : 0, "advance" : 0, "advance_count" : 0, "score" : 515381, "build_scorer_count" : 8, "create_weight" : 1618837, "shallow_advance" : 0, "create_weight_count" : 1, "build_scorer" : 2375084 }, "children" : [ { "type" : "TermQuery", 查询使用的插件 "description" : "title.keyword:2012", 查询条件 "time_in_nanos" : 397074, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 2, "set_min_competitive_score" : 0, "next_doc" : 0, "match" : 0, "next_doc_count" : 0, "score_count" : 1, "compute_max_score_count" : 1, "compute_max_score" : 46983, "advance" : 20746, "advance_count" : 2, "score" : 545, "build_scorer_count" : 5, "create_weight" : 250249, "shallow_advance" : 25677, "create_weight_count" : 1, "build_scorer" : 52862 } }, { "type" : "TermQuery", "description" : "id.keyword:2012", "time_in_nanos" : 116608, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 2, "set_min_competitive_score" : 0, "next_doc" : 0, "match" : 0, "next_doc_count" : 0, "score_count" : 1, "compute_max_score_count" : 1, "compute_max_score" : 5687, "advance" : 2404, "advance_count" : 2, "score" : 2586, "build_scorer_count" : 5, "create_weight" : 93990, "shallow_advance" : 1885, "create_weight_count" : 1, "build_scorer" : 10044 } }, { "type" : "PointRangeQuery", "description" : "year:[2012 TO 2012]", "time_in_nanos" : 2011315, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 2, "set_min_competitive_score" : 0, "next_doc" : 19773, "match" : 0, "next_doc_count" : 26, "score_count" : 216, "compute_max_score_count" : 1, "compute_max_score" : 5058, "advance" : 154907, "advance_count" : 194, "score" : 79951, "build_scorer_count" : 8, "create_weight" : 1688, "shallow_advance" : 4746, "create_weight_count" : 1, "build_scorer" : 1744744 } }, { "type" : "TermQuery", "description" : "genre:2012", "time_in_nanos" : 115362, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 0, "set_min_competitive_score" : 0, "next_doc" : 0, "match" : 0, "next_doc_count" : 0, "score_count" : 0, "compute_max_score_count" : 0, "compute_max_score" : 0, "advance" : 0, "advance_count" : 0, "score" : 0, "build_scorer_count" : 4, "create_weight" : 112019, "shallow_advance" : 0, "create_weight_count" : 1, "build_scorer" : 3338 } }, { "type" : "TermQuery", "description" : "@version:2012", "time_in_nanos" : 40376, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 0, "set_min_competitive_score" : 0, "next_doc" : 0, "match" : 0, "next_doc_count" : 0, "score_count" : 0, "compute_max_score_count" : 0, "compute_max_score" : 0, "advance" : 0, "advance_count" : 0, "score" : 0, "build_scorer_count" : 4, "create_weight" : 38910, "shallow_advance" : 0, "create_weight_count" : 1, "build_scorer" : 1461 } }, { "type" : "TermQuery", "description" : "@version.keyword:2012", "time_in_nanos" : 20377, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 0, "set_min_competitive_score" : 0, "next_doc" : 0, "match" : 0, "next_doc_count" : 0, "score_count" : 0, "compute_max_score_count" : 0, "compute_max_score" : 0, "advance" : 0, "advance_count" : 0, "score" : 0, "build_scorer_count" : 4, "create_weight" : 19159, "shallow_advance" : 0, "create_weight_count" : 1, "build_scorer" : 1213 } }, { "type" : "TermQuery", "description" : "id:2012", "time_in_nanos" : 125553, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 2, "set_min_competitive_score" : 0, "next_doc" : 0, "match" : 0, "next_doc_count" : 0, "score_count" : 1, "compute_max_score_count" : 1, "compute_max_score" : 3380, "advance" : 1560, "advance_count" : 2, "score" : 1598, "build_scorer_count" : 5, "create_weight" : 86129, "shallow_advance" : 1496, "create_weight_count" : 1, "build_scorer" : 31378 } }, { "type" : "TermQuery", "description" : "genre.keyword:2012", "time_in_nanos" : 60834, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 0, "set_min_competitive_score" : 0, "next_doc" : 0, "match" : 0, "next_doc_count" : 0, "score_count" : 0, "compute_max_score_count" : 0, "compute_max_score" : 0, "advance" : 0, "advance_count" : 0, "score" : 0, "build_scorer_count" : 4, "create_weight" : 58651, "shallow_advance" : 0, "create_weight_count" : 1, "build_scorer" : 2178 } }, { "type" : "TermQuery", "description" : "title:2012", "time_in_nanos" : 123266, "breakdown" : { "set_min_competitive_score_count" : 0, "match_count" : 0, "shallow_advance_count" : 2, "set_min_competitive_score" : 0, "next_doc" : 0, "match" : 0, "next_doc_count" : 0, "score_count" : 2, "compute_max_score_count" : 1, "compute_max_score" : 2740, "advance" : 5030, "advance_count" : 3, "score" : 4682, "build_scorer_count" : 5, "create_weight" : 86213, "shallow_advance" : 1401, "create_weight_count" : 1, "build_scorer" : 23186 } } ] } ], "rewrite_time" : 31701, "collector" : [ { "name" : "CancellableCollector", "reason" : "search_cancelled", "time_in_nanos" : 771058, "children" : [ { "name" : "SimpleTopScoreDocCollector", "reason" : "search_top_hits", "time_in_nanos" : 667578 } ] } ] } ], "aggregations" : [ ] } ] } }

  查询指定的字段,查询title值等于2012 的

GET /movies/_search?q=title:2012
{
  "profile": "true"
}






{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 11.303033,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "72378",
        "_score" : 11.303033,
        "_source" : {
          "title" : "2012",
          "@version" : "1",
          "id" : "72378",
          "genre" : [
            "Action",
            "Drama",
            "Sci-Fi",
            "Thriller"
          ],
          "year" : 2009
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "105254",
        "_score" : 5.2497,
        "_source" : {
          "title" : "Crystal Fairy & the Magical Cactus and 2012",
          "@version" : "1",
          "id" : "105254",
          "genre" : [
            "Adventure",
            "Comedy"
          ],
          "year" : 2013
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "TermQuery",
                "description" : "title:2012",   查询条件
                "time_in_nanos" : 232929,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 0,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 9977,
                  "match" : 0,
                  "next_doc_count" : 3,
                  "score_count" : 2,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 5393,
                  "build_scorer_count" : 5,
                  "create_weight" : 156659,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 60889
                }
              }
            ],
            "rewrite_time" : 12506,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 37068,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 18678
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  指定字段查询v.s 泛查询

q=title:2012   /q=2012

  

term vs Phrase

    Beautiful Mind 等效于Beautiful OR Mind   满足一个就可以

   "Beautiful Beautiful AND Mind 。Phrare查询,还要求前后顺序保持一致

term vs Phrase 测试

GET /movies/_search?q=title:Beautiful Mind
 {
   "profile": "true"
 }
{
  "took" : 42,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 20, 搜到20个结果
      "relation" : "eq"
    },
    "max_score" : 13.687479,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4995",
        "_score" : 13.687479,
        "_source" : {
          "title" : "Beautiful Mind, A",
          "@version" : "1",
          "id" : "4995",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 2001
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3912",
        "_score" : 8.723258,
        "_source" : {
          "title" : "Beautiful",
          "@version" : "1",
          "id" : "3912",
          "genre" : [
            "Comedy",
            "Drama"
          ],
          "year" : 2000
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "47404",
        "_score" : 8.576847,
        "_source" : {
          "title" : "Mind Game",
          "@version" : "1",
          "id" : "47404",
          "genre" : [
            "Adventure",
            "Animation",
            "Comedy",
            "Fantasy",
            "Romance",
            "Sci-Fi"
          ],
          "year" : 2004
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "94",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Girls",
          "@version" : "1",
          "id" : "94",
          "genre" : [
            "Comedy",
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "1046",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Thing",
          "@version" : "1",
          "id" : "1046",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3302",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful People",
          "@version" : "1",
          "id" : "3302",
          "genre" : [
            "Comedy"
          ],
          "year" : 1999
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4372",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Crazy/Beautiful",
          "@version" : "1",
          "id" : "4372",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 2001
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4242",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Creatures",
          "@version" : "1",
          "id" : "4242",
          "genre" : [
            "Comedy",
            "Crime",
            "Drama",
            "Thriller"
          ],
          "year" : 2000
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "90353",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Boy",
          "@version" : "1",
          "id" : "90353",
          "genre" : [
            "Drama"
          ],
          "year" : 2010
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "100487",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Creatures",
          "@version" : "1",
          "id" : "100487",
          "genre" : [
            "Drama",
            "Fantasy",
            "Romance"
          ],
          "year" : 2013
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "BooleanQuery",
                "description" : """title:beautiful (title.keyword:Mind | id.keyword:Mind | MatchNoDocsQuery("failed [year] query, caused by number_format_exception:[For input string: "Mind"]") | genre:mind | @version:mind | @version.keyword:Mind | id:mind | genre.keyword:Mind | title:mind)""",
                "time_in_nanos" : 32207647,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 20,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 466425,
                  "match" : 12045,
                  "next_doc_count" : 22,
                  "score_count" : 20,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 213299,
                  "build_scorer_count" : 6,
                  "create_weight" : 3357258,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 28158551
                },
                "children" : [
                  {
                    "type" : "TermQuery",
                    "description" : "title:beautiful",
                    "time_in_nanos" : 1744017,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 6,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 0,
                      "match" : 0,
                      "next_doc_count" : 0,
                      "score_count" : 16,
                      "compute_max_score_count" : 6,
                      "compute_max_score" : 38206,
                      "advance" : 57537,
                      "advance_count" : 18,
                      "score" : 181427,
                      "build_scorer_count" : 8,
                      "create_weight" : 1131525,
                      "shallow_advance" : 17684,
                      "create_weight_count" : 1,
                      "build_scorer" : 317583
                    }
                  },
                  {
                    "type" : "DisjunctionMaxQuery",
                    "description" : """(title.keyword:Mind | id.keyword:Mind | MatchNoDocsQuery("failed [year] query, caused by number_format_exception:[For input string: "Mind"]") | genre:mind | @version:mind | @version.keyword:Mind | id:mind | genre.keyword:Mind | title:mind)""",
                    "time_in_nanos" : 2366329,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 6,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 0,
                      "match" : 0,
                      "next_doc_count" : 0,
                      "score_count" : 5,
                      "compute_max_score_count" : 6,
                      "compute_max_score" : 15590,
                      "advance" : 98398,
                      "advance_count" : 7,
                      "score" : 12125,
                      "build_scorer_count" : 8,
                      "create_weight" : 2071958,
                      "shallow_advance" : 8749,
                      "create_weight_count" : 1,
                      "build_scorer" : 159476
                    },
                    "children" : [
                      {
                        "type" : "TermQuery",
                        "description" : "title.keyword:Mind",
                        "time_in_nanos" : 266169,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 0,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "compute_max_score_count" : 0,
                          "compute_max_score" : 0,
                          "advance" : 0,
                          "advance_count" : 0,
                          "score" : 0,
                          "build_scorer_count" : 4,
                          "create_weight" : 264336,
                          "shallow_advance" : 0,
                          "create_weight_count" : 1,
                          "build_scorer" : 1828
                        }
                      },
                      {
                        "type" : "TermQuery",
                        "description" : "id.keyword:Mind",
                        "time_in_nanos" : 260988,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 0,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "compute_max_score_count" : 0,
                          "compute_max_score" : 0,
                          "advance" : 0,
                          "advance_count" : 0,
                          "score" : 0,
                          "build_scorer_count" : 4,
                          "create_weight" : 259322,
                          "shallow_advance" : 0,
                          "create_weight_count" : 1,
                          "build_scorer" : 1661
                        }
                      },
                      {
                        "type" : "MatchNoDocsQuery",
                        "description" : """MatchNoDocsQuery("failed [year] query, caused by number_format_exception:[For input string: "Mind"]")""",
                        "time_in_nanos" : 4802,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 0,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "compute_max_score_count" : 0,
                          "compute_max_score" : 0,
                          "advance" : 0,
                          "advance_count" : 0,
                          "score" : 0,
                          "build_scorer_count" : 4,
                          "create_weight" : 834,
                          "shallow_advance" : 0,
                          "create_weight_count" : 1,
                          "build_scorer" : 3963
                        }
                      },
                      {
                        "type" : "TermQuery",
                        "description" : "genre:mind",
                        "time_in_nanos" : 296732,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 0,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "compute_max_score_count" : 0,
                          "compute_max_score" : 0,
                          "advance" : 0,
                          "advance_count" : 0,
                          "score" : 0,
                          "build_scorer_count" : 4,
                          "create_weight" : 295891,
                          "shallow_advance" : 0,
                          "create_weight_count" : 1,
                          "build_scorer" : 836
                        }
                      },
                      {
                        "type" : "TermQuery",
                        "description" : "@version:mind",
                        "time_in_nanos" : 139280,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 0,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "compute_max_score_count" : 0,
                          "compute_max_score" : 0,
                          "advance" : 0,
                          "advance_count" : 0,
                          "score" : 0,
                          "build_scorer_count" : 4,
                          "create_weight" : 138598,
                          "shallow_advance" : 0,
                          "create_weight_count" : 1,
                          "build_scorer" : 677
                        }
                      },
                      {
                        "type" : "TermQuery",
                        "description" : "@version.keyword:Mind",
                        "time_in_nanos" : 116205,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 0,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "compute_max_score_count" : 0,
                          "compute_max_score" : 0,
                          "advance" : 0,
                          "advance_count" : 0,
                          "score" : 0,
                          "build_scorer_count" : 4,
                          "create_weight" : 115588,
                          "shallow_advance" : 0,
                          "create_weight_count" : 1,
                          "build_scorer" : 612
                        }
                      },
                      {
                        "type" : "TermQuery",
                        "description" : "id:mind",
                        "time_in_nanos" : 209941,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 0,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "compute_max_score_count" : 0,
                          "compute_max_score" : 0,
                          "advance" : 0,
                          "advance_count" : 0,
                          "score" : 0,
                          "build_scorer_count" : 4,
                          "create_weight" : 208700,
                          "shallow_advance" : 0,
                          "create_weight_count" : 1,
                          "build_scorer" : 1236
                        }
                      },
                      {
                        "type" : "TermQuery",
                        "description" : "genre.keyword:Mind",
                        "time_in_nanos" : 148268,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 0,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 0,
                          "compute_max_score_count" : 0,
                          "compute_max_score" : 0,
                          "advance" : 0,
                          "advance_count" : 0,
                          "score" : 0,
                          "build_scorer_count" : 4,
                          "create_weight" : 147208,
                          "shallow_advance" : 0,
                          "create_weight_count" : 1,
                          "build_scorer" : 1055
                        }
                      },
                      {
                        "type" : "TermQuery",
                        "description" : "title:mind",
                        "time_in_nanos" : 647108,
                        "breakdown" : {
                          "set_min_competitive_score_count" : 0,
                          "match_count" : 0,
                          "shallow_advance_count" : 6,
                          "set_min_competitive_score" : 0,
                          "next_doc" : 0,
                          "match" : 0,
                          "next_doc_count" : 0,
                          "score_count" : 5,
                          "compute_max_score_count" : 6,
                          "compute_max_score" : 13885,
                          "advance" : 95785,
                          "advance_count" : 7,
                          "score" : 10966,
                          "build_scorer_count" : 6,
                          "create_weight" : 427668,
                          "shallow_advance" : 6655,
                          "create_weight_count" : 1,
                          "build_scorer" : 92118
                        }
                      }
                    ]
                  }
                ]
              }
            ],
            "rewrite_time" : 198085,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 373215,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 312807
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  

 

 分组与引号

title:(Beautiful AND Mind)
title="Beautiful Mind"

  

GET /movies/_search?q=title:"Beautiful Mind"
 {
   "profile": "true"
 }
{
  "took" : 75,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 13.68748,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4995",
        "_score" : 13.68748,
        "_source" : {
          "title" : "Beautiful Mind, A",
          "@version" : "1",
          "id" : "4995",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 2001
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "PhraseQuery",
                "description" : """title:"beautiful mind"""",
                "time_in_nanos" : 50328460,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 1,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 38518,
                  "match" : 14575831,
                  "next_doc_count" : 3,
                  "score_count" : 1,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 58361,
                  "build_scorer_count" : 6,
                  "create_weight" : 28740256,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 6915482
                }
              }
            ],
            "rewrite_time" : 11468,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 179228,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 129975
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  分组查询

GET /movies/_search?q=title:(Beautiful Mind)
 {
   "profile": "true"
 }


{
  "took" : 124,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 20,
      "relation" : "eq"
    },
    "max_score" : 13.687479,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4995",
        "_score" : 13.687479,
        "_source" : {
          "title" : "Beautiful Mind, A",
          "@version" : "1",
          "id" : "4995",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 2001
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3912",
        "_score" : 8.723258,
        "_source" : {
          "title" : "Beautiful",
          "@version" : "1",
          "id" : "3912",
          "genre" : [
            "Comedy",
            "Drama"
          ],
          "year" : 2000
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "47404",
        "_score" : 8.576847,
        "_source" : {
          "title" : "Mind Game",
          "@version" : "1",
          "id" : "47404",
          "genre" : [
            "Adventure",
            "Animation",
            "Comedy",
            "Fantasy",
            "Romance",
            "Sci-Fi"
          ],
          "year" : 2004
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "94",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Girls",
          "@version" : "1",
          "id" : "94",
          "genre" : [
            "Comedy",
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "1046",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Thing",
          "@version" : "1",
          "id" : "1046",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3302",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful People",
          "@version" : "1",
          "id" : "3302",
          "genre" : [
            "Comedy"
          ],
          "year" : 1999
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4372",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Crazy/Beautiful",
          "@version" : "1",
          "id" : "4372",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 2001
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4242",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Creatures",
          "@version" : "1",
          "id" : "4242",
          "genre" : [
            "Comedy",
            "Crime",
            "Drama",
            "Thriller"
          ],
          "year" : 2000
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "90353",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Boy",
          "@version" : "1",
          "id" : "90353",
          "genre" : [
            "Drama"
          ],
          "year" : 2010
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "100487",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Creatures",
          "@version" : "1",
          "id" : "100487",
          "genre" : [
            "Drama",
            "Fantasy",
            "Romance"
          ],
          "year" : 2013
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "BooleanQuery",
                "description" : "title:beautiful title:mind",
                "time_in_nanos" : 1382153,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 20,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 176512,
                  "match" : 7470,
                  "next_doc_count" : 22,
                  "score_count" : 20,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 56444,
                  "build_scorer_count" : 6,
                  "create_weight" : 538911,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 602747
                },
                "children" : [
                  {
                    "type" : "TermQuery",
                    "description" : "title:beautiful",
                    "time_in_nanos" : 572182,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 6,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 0,
                      "match" : 0,
                      "next_doc_count" : 0,
                      "score_count" : 16,
                      "compute_max_score_count" : 6,
                      "compute_max_score" : 24058,
                      "advance" : 26383,
                      "advance_count" : 18,
                      "score" : 25937,
                      "build_scorer_count" : 8,
                      "create_weight" : 349386,
                      "shallow_advance" : 6778,
                      "create_weight_count" : 1,
                      "build_scorer" : 139585
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:mind",
                    "time_in_nanos" : 221045,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 6,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 0,
                      "match" : 0,
                      "next_doc_count" : 0,
                      "score_count" : 5,
                      "compute_max_score_count" : 6,
                      "compute_max_score" : 13130,
                      "advance" : 13106,
                      "advance_count" : 7,
                      "score" : 6414,
                      "build_scorer_count" : 8,
                      "create_weight" : 114325,
                      "shallow_advance" : 11050,
                      "create_weight_count" : 1,
                      "build_scorer" : 62987
                    }
                  }
                ]
              }
            ],
            "rewrite_time" : 47686,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 142302,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 110272
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  搜索中的逻辑判断

GET /movies/_search?q=title:(Beautiful AND Mind)   :表示搜索机油Beautiful 有有mind的数据
 {
   "profile": "true"   显示过程
 }





{
  "took" : 15,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 13.687479,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4995",
        "_score" : 13.687479,
        "_source" : {
          "title" : "Beautiful Mind, A",
          "@version" : "1",
          "id" : "4995",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 2001
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "BooleanQuery",布尔查询
                "description" : "+title:beautiful +title:mind",
                "time_in_nanos" : 7813951,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 0,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 279919,
                  "match" : 0,
                  "next_doc_count" : 3,
                  "score_count" : 1,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 3951,
                  "build_scorer_count" : 6,
                  "create_weight" : 851783,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 6678287
                },
                "children" : [
                  {
                    "type" : "TermQuery",
                    "description" : "title:beautiful",
                    "time_in_nanos" : 2418058,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 6,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 0,
                      "match" : 0,
                      "next_doc_count" : 0,
                      "score_count" : 1,
                      "compute_max_score_count" : 8,
                      "compute_max_score" : 59353,
                      "advance" : 33553,
                      "advance_count" : 5,
                      "score" : 7459,
                      "build_scorer_count" : 8,
                      "create_weight" : 540623,
                      "shallow_advance" : 15162,
                      "create_weight_count" : 1,
                      "build_scorer" : 1761879
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:mind",
                    "time_in_nanos" : 499539,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 6,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 0,
                      "match" : 0,
                      "next_doc_count" : 0,
                      "score_count" : 1,
                      "compute_max_score_count" : 6,
                      "compute_max_score" : 21292,
                      "advance" : 103268,
                      "advance_count" : 7,
                      "score" : 7246,
                      "build_scorer_count" : 6,
                      "create_weight" : 277130,
                      "shallow_advance" : 10859,
                      "create_weight_count" : 1,
                      "build_scorer" : 79717
                    }
                  }
                ]
              }
            ],
            "rewrite_time" : 26637,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 171389,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 33965
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  查询制包含

GET /movies/_search?q=title:(Beautiful NOT Mind)
 {
   "profile": "true"
 }


{
  "took" : 8,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 15,
      "relation" : "eq"
    },
    "max_score" : 8.723258,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3912",
        "_score" : 8.723258,
        "_source" : {
          "title" : "Beautiful",
          "@version" : "1",
          "id" : "3912",
          "genre" : [
            "Comedy",
            "Drama"
          ],
          "year" : 2000
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "94",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Girls",
          "@version" : "1",
          "id" : "94",
          "genre" : [
            "Comedy",
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "1046",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Thing",
          "@version" : "1",
          "id" : "1046",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3302",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful People",
          "@version" : "1",
          "id" : "3302",
          "genre" : [
            "Comedy"
          ],
          "year" : 1999
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4372",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Crazy/Beautiful",
          "@version" : "1",
          "id" : "4372",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 2001
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4242",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Creatures",
          "@version" : "1",
          "id" : "4242",
          "genre" : [
            "Comedy",
            "Crime",
            "Drama",
            "Thriller"
          ],
          "year" : 2000
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "90353",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Boy",
          "@version" : "1",
          "id" : "90353",
          "genre" : [
            "Drama"
          ],
          "year" : 2010
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "100487",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Creatures",
          "@version" : "1",
          "id" : "100487",
          "genre" : [
            "Drama",
            "Fantasy",
            "Romance"
          ],
          "year" : 2013
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "114126",
        "_score" : 7.317063,
        "_source" : {
          "title" : "Beautiful Losers",
          "@version" : "1",
          "id" : "114126",
          "genre" : [
            "Documentary"
          ],
          "year" : 2008
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "2324",
        "_score" : 6.3012905,
        "_source" : {
          "title" : "Life Is Beautiful",
          "@version" : "1",
          "id" : "2324",
          "genre" : [
            "Comedy",
            "Drama",
            "Romance",
            "War"
          ],
          "year" : 0
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "BooleanQuery",
                "description" : "title:beautiful -title:mind",
                "time_in_nanos" : 1469904,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 16,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 70386,
                  "match" : 45969,
                  "next_doc_count" : 18,
                  "score_count" : 15,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 49699,
                  "build_scorer_count" : 6,
                  "create_weight" : 890155,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 413639
                },
                "children" : [
                  {
                    "type" : "TermQuery",
                    "description" : "title:beautiful",
                    "time_in_nanos" : 383415,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 22807,
                      "match" : 0,
                      "next_doc_count" : 18,
                      "score_count" : 15,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 21589,
                      "build_scorer_count" : 8,
                      "create_weight" : 222824,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 116153
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:mind",
                    "time_in_nanos" : 170932,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 0,
                      "match" : 0,
                      "next_doc_count" : 0,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 3943,
                      "advance_count" : 6,
                      "score" : 0,
                      "build_scorer_count" : 6,
                      "create_weight" : 28392,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 138584
                    }
                  }
                ]
              }
            ],
            "rewrite_time" : 37877,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 126287,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 70553
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  查询数字

 GET /movies/_search?q=year:>=1980  查询大于等于1980的
 {
   "profile": "true"
 }
 
 


{
  "took" : 29,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 7350,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "title" : "Grumpier Old Men",
          "@version" : "1",
          "id" : "3",
          "genre" : [
            "Comedy",
            "Romance"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "7",
        "_score" : 1.0,
        "_source" : {
          "title" : "Sabrina",
          "@version" : "1",
          "id" : "7",
          "genre" : [
            "Comedy",
            "Romance"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "11",
        "_score" : 1.0,
        "_source" : {
          "title" : "American President, The",
          "@version" : "1",
          "id" : "11",
          "genre" : [
            "Comedy",
            "Drama",
            "Romance"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "15",
        "_score" : 1.0,
        "_source" : {
          "title" : "Cutthroat Island",
          "@version" : "1",
          "id" : "15",
          "genre" : [
            "Action",
            "Adventure",
            "Romance"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "19",
        "_score" : 1.0,
        "_source" : {
          "title" : "Ace Ventura: When Nature Calls",
          "@version" : "1",
          "id" : "19",
          "genre" : [
            "Comedy"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "27",
        "_score" : 1.0,
        "_source" : {
          "title" : "Now and Then",
          "@version" : "1",
          "id" : "27",
          "genre" : [
            "Children",
            "Drama"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "title" : "Jumanji",
          "@version" : "1",
          "id" : "2",
          "genre" : [
            "Adventure",
            "Children",
            "Fantasy"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "31",
        "_score" : 1.0,
        "_source" : {
          "title" : "Dangerous Minds",
          "@version" : "1",
          "id" : "31",
          "genre" : [
            "Drama"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "5",
        "_score" : 1.0,
        "_source" : {
          "title" : "Father of the Bride Part II",
          "@version" : "1",
          "id" : "5",
          "genre" : [
            "Comedy"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "18",
        "_score" : 1.0,
        "_source" : {
          "title" : "Four Rooms",
          "@version" : "1",
          "id" : "18",
          "genre" : [
            "Comedy"
          ],
          "year" : 1995
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "IndexOrDocValuesQuery",
                "description" : "year:[1980 TO 9223372036854775807]",
                "time_in_nanos" : 25227751,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 0,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 14575878,
                  "match" : 0,
                  "next_doc_count" : 7354,
                  "score_count" : 7350,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 1093078,
                  "build_scorer_count" : 8,
                  "create_weight" : 11725,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 9532357
                }
              }
            ],
            "rewrite_time" : 3423,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 2649860,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 1820928
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  通配符查询

 GET /movies/_search?q=title:b*
 {
   "profile": "true"
   
 } 



{
  "took" : 41,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1540,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "5",
        "_score" : 1.0,
        "_source" : {
          "title" : "Father of the Bride Part II",
          "@version" : "1",
          "id" : "5",
          "genre" : [
            "Comedy"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "105",
        "_score" : 1.0,
        "_source" : {
          "title" : "Bridges of Madison County, The",
          "@version" : "1",
          "id" : "105",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "54",
        "_score" : 1.0,
        "_source" : {
          "title" : "Big Green, The",
          "@version" : "1",
          "id" : "54",
          "genre" : [
            "Children",
            "Comedy"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "156",
        "_score" : 1.0,
        "_source" : {
          "title" : "Blue in the Face",
          "@version" : "1",
          "id" : "156",
          "genre" : [
            "Comedy",
            "Drama"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "249",
        "_score" : 1.0,
        "_source" : {
          "title" : "Immortal Beloved",
          "@version" : "1",
          "id" : "249",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 1994
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "93",
        "_score" : 1.0,
        "_source" : {
          "title" : "Vampire in Brooklyn",
          "@version" : "1",
          "id" : "93",
          "genre" : [
            "Comedy",
            "Horror",
            "Romance"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "147",
        "_score" : 1.0,
        "_source" : {
          "title" : "Basketball Diaries, The",
          "@version" : "1",
          "id" : "147",
          "genre" : [
            "Drama"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "94",
        "_score" : 1.0,
        "_source" : {
          "title" : "Beautiful Girls",
          "@version" : "1",
          "id" : "94",
          "genre" : [
            "Comedy",
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "110",
        "_score" : 1.0,
        "_source" : {
          "title" : "Braveheart",
          "@version" : "1",
          "id" : "110",
          "genre" : [
            "Action",
            "Drama",
            "War"
          ],
          "year" : 1995
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "113",
        "_score" : 1.0,
        "_source" : {
          "title" : "Before and After",
          "@version" : "1",
          "id" : "113",
          "genre" : [
            "Drama",
            "Mystery"
          ],
          "year" : 1996
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "MultiTermQueryConstantScoreWrapper",
                "description" : "title:b*",
                "time_in_nanos" : 23928099,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 0,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 457728,
                  "match" : 0,
                  "next_doc_count" : 1544,
                  "score_count" : 1540,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 84292,
                  "build_scorer_count" : 8,
                  "create_weight" : 434490,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 22948496
                }
              },
              {
                "type" : "BooleanQuery",
                "description" : "title:baby title:bad title:bed title:bedlam title:being title:beverly title:beyond title:bio title:bites title:bitter title:black title:blue title:boy title:bushwhacked",
                "time_in_nanos" : 1274383,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 0,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 52447,
                  "match" : 0,
                  "next_doc_count" : 17,
                  "score_count" : 0,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 0,
                  "build_scorer_count" : 2,
                  "create_weight" : 447017,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 774899
                },
                "children" : [
                  {
                    "type" : "TermQuery",
                    "description" : "title:baby",
                    "time_in_nanos" : 256584,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 3350,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 188080,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 65148
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:bad",
                    "time_in_nanos" : 31994,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1168,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 10277,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 20543
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:bed",
                    "time_in_nanos" : 26018,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 839,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 9261,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 15912
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:bedlam",
                    "time_in_nanos" : 20727,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 820,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7090,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 12811
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:being",
                    "time_in_nanos" : 21723,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1279,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7875,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 12563
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:beverly",
                    "time_in_nanos" : 22228,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 908,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7084,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 14230
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:beyond",
                    "time_in_nanos" : 25307,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1860,
                      "match" : 0,
                      "next_doc_count" : 3,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 8711,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 14729
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:bio",
                    "time_in_nanos" : 21461,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1350,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 6481,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 13624
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:bites",
                    "time_in_nanos" : 21668,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 890,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 8412,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 12360
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:bitter",
                    "time_in_nanos" : 23732,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 3518,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7653,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 12555
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:black",
                    "time_in_nanos" : 20238,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 752,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 6197,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 13283
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:blue",
                    "time_in_nanos" : 25834,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 4747,
                      "match" : 0,
                      "next_doc_count" : 3,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7765,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 13315
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:boy",
                    "time_in_nanos" : 21237,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 2570,
                      "match" : 0,
                      "next_doc_count" : 3,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 6006,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 12654
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:bushwhacked",
                    "time_in_nanos" : 20675,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 860,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 6441,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 13368
                    }
                  }
                ]
              },
              {
                "type" : "BooleanQuery",
                "description" : "title:before title:big title:black title:blue title:body title:book title:born title:bride title:brothers title:buddha title:burnt title:butterfly title:by",
                "time_in_nanos" : 975206,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 0,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 40646,
                  "match" : 0,
                  "next_doc_count" : 14,
                  "score_count" : 0,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 0,
                  "build_scorer_count" : 2,
                  "create_weight" : 298985,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 635558
                },
                "children" : [
                  {
                    "type" : "TermQuery",
                    "description" : "title:before",
                    "time_in_nanos" : 130485,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 4076,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 30757,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 95646
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:big",
                    "time_in_nanos" : 39509,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1542,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 14375,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 23586
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:black",
                    "time_in_nanos" : 27187,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 986,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 8771,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 17424
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:blue",
                    "time_in_nanos" : 34339,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 6288,
                      "match" : 0,
                      "next_doc_count" : 3,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 9721,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 18323
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:body",
                    "time_in_nanos" : 23565,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 712,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7177,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 15670
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:book",
                    "time_in_nanos" : 23485,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1104,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 10276,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 12099
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:born",
                    "time_in_nanos" : 21698,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 724,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 8338,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 12630
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:bride",
                    "time_in_nanos" : 24893,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1074,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 9472,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 14341
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:brothers",
                    "time_in_nanos" : 20560,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 872,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7749,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 11933
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:buddha",
                    "time_in_nanos" : 23335,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1074,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 8948,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 13307
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:burnt",
                    "time_in_nanos" : 22335,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 1185,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7311,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 13833
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:butterfly",
                    "time_in_nanos" : 18810,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 654,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 6377,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 11773
                    }
                  },
                  {
                    "type" : "TermQuery",
                    "description" : "title:by",
                    "time_in_nanos" : 21635,
                    "breakdown" : {
                      "set_min_competitive_score_count" : 0,
                      "match_count" : 0,
                      "shallow_advance_count" : 0,
                      "set_min_competitive_score" : 0,
                      "next_doc" : 731,
                      "match" : 0,
                      "next_doc_count" : 2,
                      "score_count" : 0,
                      "compute_max_score_count" : 0,
                      "compute_max_score" : 0,
                      "advance" : 0,
                      "advance_count" : 0,
                      "score" : 0,
                      "build_scorer_count" : 3,
                      "create_weight" : 7176,
                      "shallow_advance" : 0,
                      "create_weight_count" : 1,
                      "build_scorer" : 13722
                    }
                  }
                ]
              }
            ],
            "rewrite_time" : 2045242,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 539403,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 298562
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

 模糊与近似度查询

 GET /movies/_search?q=title:beautifl~1  表示后面有一个单词或者没有
 {
   "profile": "true"
 }



{
  "took" : 12,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 16,
      "relation" : "eq"
    },
    "max_score" : 7.632851,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3912",
        "_score" : 7.632851,
        "_source" : {
          "title" : "Beautiful",
          "@version" : "1",
          "id" : "3912",
          "genre" : [
            "Comedy",
            "Drama"
          ],
          "year" : 2000
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "94",
        "_score" : 6.4024305,
        "_source" : {
          "title" : "Beautiful Girls",
          "@version" : "1",
          "id" : "94",
          "genre" : [
            "Comedy",
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "1046",
        "_score" : 6.4024305,
        "_source" : {
          "title" : "Beautiful Thing",
          "@version" : "1",
          "id" : "1046",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 1996
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "3302",
        "_score" : 6.4024305,
        "_source" : {
          "title" : "Beautiful People",
          "@version" : "1",
          "id" : "3302",
          "genre" : [
            "Comedy"
          ],
          "year" : 1999
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4372",
        "_score" : 6.4024305,
        "_source" : {
          "title" : "Crazy/Beautiful",
          "@version" : "1",
          "id" : "4372",
          "genre" : [
            "Drama",
            "Romance"
          ],
          "year" : 2001
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4242",
        "_score" : 6.4024305,
        "_source" : {
          "title" : "Beautiful Creatures",
          "@version" : "1",
          "id" : "4242",
          "genre" : [
            "Comedy",
            "Crime",
            "Drama",
            "Thriller"
          ],
          "year" : 2000
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "90353",
        "_score" : 6.4024305,
        "_source" : {
          "title" : "Beautiful Boy",
          "@version" : "1",
          "id" : "90353",
          "genre" : [
            "Drama"
          ],
          "year" : 2010
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "100487",
        "_score" : 6.4024305,
        "_source" : {
          "title" : "Beautiful Creatures",
          "@version" : "1",
          "id" : "100487",
          "genre" : [
            "Drama",
            "Fantasy",
            "Romance"
          ],
          "year" : 2013
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "114126",
        "_score" : 6.4024305,
        "_source" : {
          "title" : "Beautiful Losers",
          "@version" : "1",
          "id" : "114126",
          "genre" : [
            "Documentary"
          ],
          "year" : 2008
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "2324",
        "_score" : 5.5136294,
        "_source" : {
          "title" : "Life Is Beautiful",
          "@version" : "1",
          "id" : "2324",
          "genre" : [
            "Comedy",
            "Drama",
            "Romance",
            "War"
          ],
          "year" : 0
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "BoostQuery",
                "description" : "(title:beautiful)^0.875",
                "time_in_nanos" : 2680392,
                "breakdown" : {
                  "set_min_competitive_score_count" : 6,
                  "match_count" : 0,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 4771,
                  "next_doc" : 2484452,
                  "match" : 0,
                  "next_doc_count" : 18,
                  "score_count" : 16,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 45819,
                  "build_scorer_count" : 6,
                  "create_weight" : 35055,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 110248
                }
              }
            ],
            "rewrite_time" : 6549837,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 170052,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 89352
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  查找中间有两个的数据

GET /movies/_search?q=title:"Lord Rings"~2
 {
   "profile": "true"
 }


{
  "took" : 5,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4,
      "relation" : "eq"
    },
    "max_score" : 4.700435,
    "hits" : [
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "2116",
        "_score" : 4.700435,
        "_source" : {
          "title" : "Lord of the Rings, The",
          "@version" : "1",
          "id" : "2116",
          "genre" : [
            "Adventure",
            "Animation",
            "Children",
            "Fantasy"
          ],
          "year" : 1978
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "5952",
        "_score" : 3.2970178,
        "_source" : {
          "title" : "Lord of the Rings: The Two Towers, The",
          "@version" : "1",
          "id" : "5952",
          "genre" : [
            "Adventure",
            "Fantasy"
          ],
          "year" : 2002
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "4993",
        "_score" : 2.7496965,
        "_source" : {
          "title" : "Lord of the Rings: The Fellowship of the Ring, The",
          "@version" : "1",
          "id" : "4993",
          "genre" : [
            "Adventure",
            "Fantasy"
          ],
          "year" : 2001
        }
      },
      {
        "_index" : "movies",
        "_type" : "_doc",
        "_id" : "7153",
        "_score" : 2.7496965,
        "_source" : {
          "title" : "Lord of the Rings: The Return of the King, The",
          "@version" : "1",
          "id" : "7153",
          "genre" : [
            "Action",
            "Adventure",
            "Drama",
            "Fantasy"
          ],
          "year" : 2003
        }
      }
    ]
  },
  "profile" : {
    "shards" : [
      {
        "id" : "[v0XQ31q0QT6yQONxMu8bfw][movies][0]",
        "searches" : [
          {
            "query" : [
              {
                "type" : "PhraseQuery",
                "description" : """title:"lord rings"~2""",
                "time_in_nanos" : 527921,
                "breakdown" : {
                  "set_min_competitive_score_count" : 0,
                  "match_count" : 4,
                  "shallow_advance_count" : 0,
                  "set_min_competitive_score" : 0,
                  "next_doc" : 14633,
                  "match" : 90179,
                  "next_doc_count" : 6,
                  "score_count" : 4,
                  "compute_max_score_count" : 0,
                  "compute_max_score" : 0,
                  "advance" : 0,
                  "advance_count" : 0,
                  "score" : 6232,
                  "build_scorer_count" : 6,
                  "create_weight" : 229906,
                  "shallow_advance" : 0,
                  "create_weight_count" : 1,
                  "build_scorer" : 186950
                }
              }
            ],
            "rewrite_time" : 2161,
            "collector" : [
              {
                "name" : "CancellableCollector",
                "reason" : "search_cancelled",
                "time_in_nanos" : 31196,
                "children" : [
                  {
                    "name" : "SimpleTopScoreDocCollector",
                    "reason" : "search_top_hits",
                    "time_in_nanos" : 14153
                  }
                ]
              }
            ]
          }
        ],
        "aggregations" : [ ]
      }
    ]
  }
}

  

 

es 的搜索

标签:dram   ant   exception   测试   mys   ges   通配符   搜索   etop   

原文地址:https://www.cnblogs.com/rdchenxi/p/11841045.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!